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. THESE ARE NOT DASHES, THESE ARE GRAPHICAL LINES SIMILAR TO WHAT WE DRAW IN PAINTBRUSH.
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 1992 sicarie 4,677
Recognized Expert Moderator Specialist
It looks like you have the coordinates of the lines in your program. Why not just compare the x's?
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: vronskij |
last post by:
Hi,
A C program can be hundreds of thousands lines of code big.
C++ millions.
How about Python?
Suppose , you are a sole programmer (lonewolf). How many lines can one handle?
Thanks,
|
by: hamil |
last post by:
I am trying to print a graphic file (tif) and also use the PrintPreview
control, the PageSetup control, and the Print dialog control. The code
attached is a concatination of two examples taken out...
|
by: Bosconian |
last post by:
I'm looking for a method to plot graphic lines and text for a bracket-like
display with multiple tiers in a browser. I'm familiar with GD for
outputting dynamic graphics, but have never utilized...
|
by: JoeC |
last post by:
I am a self taught programmer and I have figured out most syntax but
desigining my programs is a challenge. I realize that there are many
ways to design a program but what are some good rules to...
|
by: Jvzj017 |
last post by:
For this assignment you will write a function which takes as parameters the upper left corner of a button and a string representing the "label" of the button. The function will write the label to the...
| |
by: André |
last post by:
Hi,
I made a webform for a survey, with multiple-choice questions. The results
of each question is put into a table e.g.:
values frequency
1 6
2 3
3 32
4 ...
|
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"...
|
by: lifeisgreat20009 |
last post by:
I want to make a "GRAPHICS PROGRAM" in C language that shows sorting of lines. Something like this:-
------------
-------------------
------
------------------------------------
after...
|
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...
|
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,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |
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...
|
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...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
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 ...
| |
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...
| |