I want to make a "GRAPHICS PROGRAM" in C language that shows sorting of lines. Something like this:-
------------
-------------------
------
------------------------------------
after sorting the lines should appear as follows on the screen :-
-------
-----------------
---------------------
--------------------------------------
NOTE :- The lines are to be drawn using line() function. also the lines are to be sorted using quick sort algorithm.
Any help would be greatly appreciated.
Thanks !!!!!
I have tried it but it fails to work . The code is below !!!!!! -
#include <graphics.h>
-
#include <stdlib.h>
-
#include <stdio.h>
-
#include <conio.h>
-
-
int main(void)
-
{
-
/* request auto detection */
-
int gdriver = DETECT, gmode, errorcode;
-
-
int x1=50,y1=50,x2=100,y2=50,x3=70,y3=70,x4=150,y4=70;
-
int x5=30,y5=90,x6=50,y6=90,i,l[3],temp,midx,midy;
-
-
-
-
/* initialize graphics and local variables */
-
initgraph(&gdriver, &gmode, "");
-
-
/* read result of initialization */
-
errorcode = graphresult();
-
/* an error occurred */
-
if (errorcode != grOk)
-
{
-
printf("Graphics error: %s\n", grapherrormsg(errorcode));
-
printf("Press any key to halt:");
-
getch();
-
exit(1);
-
}
-
midx=getmaxx()/2;
-
midy=getmaxy()/2;
-
outtextxy(midx-50,10,"UNSORTED LINES");
-
outtextxy(midx-50,midy-130,"SORTED LINES");
-
line(0,0,getmaxx(),0);
-
line(getmaxx(),0,getmaxx(),getmaxy());
-
line(getmaxx(),getmaxy(),0,getmaxy());
-
line(0,0,0,getmaxy());
-
-
setcolor('5');
-
line(x1,y1,x2,y2);
-
line(x3,y3,x4,y4);
-
line(x5,y5,x6,y6);
-
-
l[0]=x2-x1;
-
l[1]=x4-x3;
-
l[2]=x6-x5;
-
delay(1000);
-
for(i=0;i<=2;i++)
-
{
-
if(l[i]>l[i+1])
-
{
-
temp=l[i];
-
l[i]=l[i+1];
-
l[i+1]=temp;
-
-
} } delay(1000);
-
-
line(x1,y1+110,l[0]+x1,y1+110); delay(1000);
-
line(x1,y1+130,l[1]+x1,y1+130); delay(1000);
-
line(x1,y1+150,l[2]+x1,y1+150);
-
-
-
getch();
-
closegraph();
-
return 0;
-
}
1 1727
You could save yourself a lot of trouble by just looking at each integer and displaying dashes corresponding to the integer value.
That is, if it contains 5, you display - - - - - followed by a newline.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: frank |
last post by:
Hi all
I don't think this is strictly a Python problem, but as it manifests
itself in one of my Python programs, I am hoping that somebody in this
group can help me.
The following is a message I sent to co.os.linux.setup -
"My question concerns line graphics on a text-based console. My
actual problem relates to a program I have...
|
by: Mark Johnson |
last post by:
Using: VS 2003 NET C# for Framework and Framework Compact
Trying : Moving a Card (Bitmap) as in Solitare (PC + WinCe) Version on
OnMouseMove
Problem : The affected drawing Area by Invalidate (or Invalidate(Rectangle))
flickers in a nasty way when repainting.
This does not happen in the Solitare (PC + WinCe) Versions a well as in a
Card...
|
by: Galen Somerville |
last post by:
Going from VB6 (RAD) to VB2005 (SAD)
The documentation always shows graphics drawing in a paint event like
Private Sub Pictcolor_Paint(ByVal sender As Object, ByVal e _
As System.Windows.Forms.PaintEventArgs) Handles PictColor.Paint
End Sub
But my VB6 program draws to the picturebox PictColor from many different
|
by: Ground21 |
last post by:
Hello. I'm new // sorry for my english :)
I have to write simple program i c++.
But I don't know how to code src - program should know it's name
(unit1.exe so the name is "unit1" or "unit1.exe" and it's full path
(with volume name - c:\programs).
Which commends of c++ should I use?
(please do not redirect me to 'help', because I must...
|
by: Xah Lee |
last post by:
Of Interest:
Introduction to 3D Graphics Programing
http://xahlee.org/3d/index.html
Currently, this introduction introduces you to the graphics format of
Mathematica, and two Java Applet utilities that allows you to view them
with live rotation in a web browser. Also, it includes a introductory
tutorial to POV-Ray.
| |
by: tomy |
last post by:
Hi All
I am a newbie to turtle graphics in python, so sorry if you find this
question too easy.
How can I get smoother lines in turtle graphics?
I am using python on windows.
Thanks in advance
|
by: Dilip |
last post by:
Howdy Folks
I have a display where the Graphics.DrawString function is called to
display something. Since the text seems to be larger than its
bounding rectangle, the call basically splits the string into multiple
lines.
Is there a way to find out into how many lines the string was split?
I am asking because this string is being...
|
by: raylopez99 |
last post by:
Hi,
I'm getting into GDI+ Forms 2.0 graphics for C#3 using Visual Studio
2008.
One thing I notice: the graphics are really slow and flicker on a
Pentium IV, with 2 GB RAM, even with doublebuffering turned on.
I did learn tricks such as not invalidating everything, but just the
control that is part of the form you are working on (i.e.,
|
by: slapsh0t11 |
last post by:
Hello! I need help with a program that I believe I am nearly done with. However, there seems to be a few details that preclude me from success. Here is my assignment:
Here is my class file (Sorts.java):
import java.util.*;
/**
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...
| |