
这个wintc程序为什么一闪而过 10
/*中点画圆法方刷*/#include<graphics.h>#include<stdio.h>#include<conio.h>#include<stdlib.h>vo...
/*中点画圆法方刷*/
#include<graphics.h>
#include<stdio.h>
#include<conio.h>
#include <stdlib.h>
void initgr(void)
{ int gd = DETECT, gm = 0;
registerbgidriver(EGAVGA_driver);
initgraph(&gd,&gm,"");
}
void circlePlotPoints(int xCenter,int yCenter,int x, int y,int halfwidth,int Color) /*利用对称性画出圆上的点*/
{ int px,py;
for(py=y-halfwidth;py<=y+halfwidth;py++)
for(px=x-halfwidth;px<=x+halfwidth;px++)
{
if(Color!=getpixel(px,py))
{
putpixel(xCenter+px,yCenter+py,Color);
putpixel(xCenter-px,yCenter+py,Color);
putpixel(xCenter+px,yCenter-py,Color);
putpixel(xCenter-px,yCenter-py,Color);
putpixel(xCenter+py,yCenter+px,Color);
putpixel(xCenter-py,yCenter+px,Color);
putpixel(xCenter+py,yCenter-px,Color);
putpixel(xCenter-py,yCenter-px,Color);
}
}
delay(1000);
}
void circleMidpoint(int xCenter,int yCenter,int radius,int halfwidth,int color) /*不含浮点运算,画8分之1圆*/
{ int x=0, y=radius,p=1-radius;
circlePlotPoints(xCenter,yCenter,x,y,halfwidth,color);
while(x<y)
{ x++;
if(p<0)p+=2*x+1;
else { y--; p+=2*(x-y)+1; }
circlePlotPoints(xCenter,yCenter,x,y,halfwidth,color);
}
}
void main()
{ int xCenter=300,yCenter=200,radius=180,halfwidth=2,color=YELLOW;
/* printf("input the center,radius,halfwidth and color of circle:(x0,y0,radius,halfwidth,color)\n");
scanf("%d,%d,%d,%d,%d",&xCenter,&yCenter,&radius,&halfwidth,&color);*/
initgr(); setbkcolor(BLUE);
circleMidpoint(xCenter,yCenter,radius,halfwidth,color); system("pause");
getch(); closegraph(); return 0;
}
在我电脑上运行的时候是闪过的 是不是系统的原因? 展开
#include<graphics.h>
#include<stdio.h>
#include<conio.h>
#include <stdlib.h>
void initgr(void)
{ int gd = DETECT, gm = 0;
registerbgidriver(EGAVGA_driver);
initgraph(&gd,&gm,"");
}
void circlePlotPoints(int xCenter,int yCenter,int x, int y,int halfwidth,int Color) /*利用对称性画出圆上的点*/
{ int px,py;
for(py=y-halfwidth;py<=y+halfwidth;py++)
for(px=x-halfwidth;px<=x+halfwidth;px++)
{
if(Color!=getpixel(px,py))
{
putpixel(xCenter+px,yCenter+py,Color);
putpixel(xCenter-px,yCenter+py,Color);
putpixel(xCenter+px,yCenter-py,Color);
putpixel(xCenter-px,yCenter-py,Color);
putpixel(xCenter+py,yCenter+px,Color);
putpixel(xCenter-py,yCenter+px,Color);
putpixel(xCenter+py,yCenter-px,Color);
putpixel(xCenter-py,yCenter-px,Color);
}
}
delay(1000);
}
void circleMidpoint(int xCenter,int yCenter,int radius,int halfwidth,int color) /*不含浮点运算,画8分之1圆*/
{ int x=0, y=radius,p=1-radius;
circlePlotPoints(xCenter,yCenter,x,y,halfwidth,color);
while(x<y)
{ x++;
if(p<0)p+=2*x+1;
else { y--; p+=2*(x-y)+1; }
circlePlotPoints(xCenter,yCenter,x,y,halfwidth,color);
}
}
void main()
{ int xCenter=300,yCenter=200,radius=180,halfwidth=2,color=YELLOW;
/* printf("input the center,radius,halfwidth and color of circle:(x0,y0,radius,halfwidth,color)\n");
scanf("%d,%d,%d,%d,%d",&xCenter,&yCenter,&radius,&halfwidth,&color);*/
initgr(); setbkcolor(BLUE);
circleMidpoint(xCenter,yCenter,radius,halfwidth,color); system("pause");
getch(); closegraph(); return 0;
}
在我电脑上运行的时候是闪过的 是不是系统的原因? 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询