#include <iostream>
#include <conio.h>
using namespace std;
int main(){
int xc,yc,x,y,p,r;
int gdriver = DETECT, gmode;
initgraph(&gdriver,&gmode,"c:\\turboc3\\bgi");
cout<<"Enter co-ordinate for centre of circle:";
cin>>xc>>yc;
cout<<"Enter radius of circle: ";
cin>>r;
x = 0;
y = r;
p = 1-r;
while(x<=y){
if(p<0){
x=x+1;
y=y+0;
p=p+2*x +1;
}
else{
x=x+1;
y=y-1;
p=p+2*x-2*y+1;
}
putpixel(xc+x,yc+y,WHITE);
putpixel(xc+y,yc+x,WHITE);
putpixel(xc+x,yc-y,WHITE);
putpixel(xc+y,yc-x,WHITE);
putpixel(xc-x,yc-y,WHITE);
putpixel(xc-y,yc-x,WHITE);
putpixel(xc-x,yc+y,WHITE);
putpixel(xc-y,yc+x,WHITE);
delay(100);
}
getch();
closegraph();
return 0;
}
0 comments:
Post a Comment