Apr 27, 2012 at 2:51pm UTC
Heya, I've been trying to draw a circle but I can't seem to manage that. What could be wrong here;
void drawCircle(struct circle body, struct canvas pic, char symbol){
long double r = body.r;
long double x = body.x;
long double y = body.y;
for(int i=0 ; i<=pic.height ; i++)
{
for(int m=0 ; m<=pic.width ; m++)
{
if(int(sqrt((x-i)*(x-i)+(y-m)*(y-m))<=r))
{
arr_canvas[i][m] = symbol;
}
}
}
for (int i = 0; i < pic.height; i++){
for (int m= 0; m < pic.width; m++){
cout << arr_canvas[i][m];
}
cout << endl;
}
return;
}
struct circle getCirclexyr(string str){
struct circle body;
string l[3];
int pos[3] ;
pos[0] = str.find(" ");
for(int i=0; i < 3; ++i){
pos[i+1] = str.find(" ", pos[i]+1);
l[i] = str.substr(pos[i]+1, pos[i+1] - pos[i]-1);
}
body.x = atoi(l[0].c_str());
body.y = atoi(l[1].c_str());
body.r = atoi(l[2].c_str());
return body;
}
Apr 27, 2012 at 5:35pm UTC
1: You need to post your code in [code ][ /code] tags
2. You need to post what error your compiler is throwing/what results are you getting when running the program(if no compilation error occurs)
Last edited on Apr 27, 2012 at 5:35pm UTC