要求使用c或c++编写用Bresenham算法生成逆时针方向的位于第一象限的一段圆弧的算法
#include<graphics.h>#include<stdio.h>
#include<conio.h>
#include<math.h>
void circlepoint(int x,int y,int color)
{
putpixel(y+200,-x+200,color);
putpixel(x+200,-y+200,color);
}
void midbresenhamcircle(int r,int color)
{
int x,y,d;
x=0;y=r;d=1-r;
while(x<=y)
{
circlepoint(x,y,color);
if(d<0)
d+=2*x+3;
else
{
d+=2*(x-y)+5;
y--;
}
x++;
}
}
void main()
{
int gd,gm;
int r;
gd=DETECT;
initgraph(&gd,&gm,"e:\tc2.0");
printf("please input circle r:");
scanf("%d",&r);
midbresenhamcircle(r,2);
getch();
closegraph();
}