Your professor gave you a function free of charge called outtextxy( ). Worst case scenario, why not just call outtextxy() individually for every ascii character that you will to output on the dos console to draw your circle?
This may seem inefficient, but here is a way to at least make your code look 'better':
struct coord{
int x;
int y;
};
void draw_circle();
coord point[80];
//This is where it sucks.. it's up to you to come up with this list of coordinates
//through trial-and-error.
point[0].x = 10; point[0].y = 15;
point[1].x = 11; point[1].y = 14;
point[2].x = 12; point[2].y = 14;
point[3].x = 13; point[3].y = 13;
point[4].x = 14; point[4].y = 13;
...
...
...
point[79].x = 9; point[79].y = 16;
void draw_circle()
{
for(int i=0; i<80; i++)
{
outtextxy(point[i].x, point[i].y);
}
}
Although this looks brutally painful, I believe this is an appropriate technique for your level of academics. This will involve a lot of trial-and-error (having to recompile and run your program after every 'guess' of where to plot the next point for your circle) but after you've done the hard part of getting all those coordinate positions, the rest is easy.
One thing that will ease the pain: buy some graph paper. Once you get your circle started, it will be quite easy to forecast the majority of the remainder of coordinates for your ascii circle. This will help you ensure that all points are roughly at a 25 unit radius.
Other alternatives would be to look online for information on how to draw an ascii circle... your professor would undoubtedly ask where you got this information as some of these functions are quite complex... specifically the Bresenham Circle .
Clinton Portis
Practically a Posting Shark
833 posts since Oct 2005
Reputation Points: 237
Solved Threads: 118
void draw_circle()
{
for(int i=0; i<80; i++)
{
outtextxy(point[i].x, point[i].y);
cout << '*';
}
}
Clinton Portis
Practically a Posting Shark
833 posts since Oct 2005
Reputation Points: 237
Solved Threads: 118
Not exactly sure if this will help but the equation to a circle is :
//Cartesian coordinate
X^2 + Y^2 = R^2
//polar coordinate
//R = radius
sin^2(x)* R + cos^2(X) * R = 1
firstPerson
Senior Poster
3,923 posts since Dec 2008
Reputation Points: 841
Solved Threads: 608