#include<stdio.h>
#include<stdlib.h>
#include<graphics.h>
#include<math.h>
void MidBrehansemCircle(int x, int y, int radius);
int main()
{
int gdriver = DETECT, gmove;
int x, y, radius;
printf("Please input circle corner:\n");
scanf("%d%d", &x, &y);
printf("Please input circle radius:\n");
scanf("%d", &radius);
initgraph(&gdriver, &gmove, "");
MidBrehansemCircle(x, y, radius);
system("pause");
closegraph();
return 0;
}
void MidBrehansemCircle(int x, int y, int radius)
{
int d0 = 1-radius, di,x0=0,y0=radius;
di = d0;
while (x0<=y0)
{
putpixel(x0+x, y0+y, RED); //45-90
putpixel(y0+y, x0+x, YELLOW); //0-45
putpixel(x-x0, y0 + y, BLUE); //90-135
putpixel( y- y0, x+x0, WHITE); //135-180
putpixel( x- x0, y- y0, RED); //225-270
putpixel( y- y0, x- x0, YELLOW);//180-225
putpixel(x0+x, y- y0, BLUE); //270-315
putpixel(y0+y, x- x0, WHITE); //315-360
if (di >= 0)
{
di += 2 * (x0 - y0) + 5;
y0--;
}
else
di += 2 * x0 + 3;
x0++;
}
}