Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <conio.h>
- #include <graphics.h>
- void drawPoints(int, int, int, int);
- void drawCircle(int xc, int yc, int r){
- int x0,y0,p;
- x0=0;
- y0=r;
- p=1-r;
- while(x0<y0){
- if(p<0){
- x0=x0+1;
- p=p+(2*x0)+1;
- }
- else{
- x0=x0+1;
- y0=y0-1;
- p=p+(2*x0+1-(2*y0));
- }
- drawPoints(x0,y0,xc,yc);
- }
- }
- void drawPoints(int x, int y, int xc, int yc){
- putpixel(xc+x,yc+y,5);
- putpixel(xc-x,yc+y,5); `
- putpixel(xc+x,yc-y,5);
- putpixel(xc-x,yc-y,5);
- putpixel(xc+y,yc+x,5);
- putpixel(xc-y,yc+x,5);
- putpixel(xc+y,yc-x,5);
- putpixel(xc-y,yc-x,5);
- }
- int main()
- {
- int xc, yc, r;
- int gdriver=DETECT, gmode;
- initgraph(&gdriver,&gmode,"C:\\TURBOC3\\BGI");
- printf("Enter the centre of the circle:\n");
- scanf("%d%d",&xc,&yc);
- printf("Enter the radius of the circle:\n");
- scanf("%d",&r);
- clrscr();
- drawCircle(xc,yc,r);
- getch();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement