#include<graphics.h>
#include<math.h>
#define FNX(x1) (int)(x+(x1)*sl)
#define FNY(y1) (int)(MAXY-(y+(y1)*sl))
#define R(theta) 1-pow(cos(1*theta),1)
int sl=50,MAXY
float x1,y1,xs,ys,r,theta
/*画心*/
void draw(int x,int y)
{
for(theta=0theta<2*3.14theta+=0.01)
{r=R(theta)
x1=r*sin(theta)y1=r*cos(theta)
xs=FNX(x1)ys=FNY(y1)
if(theta==0)moveto(xs,ys)else lineto(xs,ys)
}
}
/启迅*画箭头*/
void jian()
{
line(205,235,200,240)
line(200,240,205,245)
line(200,240,214,240)
line(400,240,500,240)
line(485,235,480,240)
line(480,240,485,245)
line(490,235,485,240)
line(485,240,490,245)
line(495,235,490,240)
line(490,240,495,245)
line(500,235,495,240)
line(495,240,500,245)
line(505,235,500,240)
line(500,240,505,245)
line(485,235,505,235)
line(485,245,505,245)
}
/*主程序*/
main()
{int driver=DETECT,mode
initgraph(&driver,&mode,"")
setbkcolor(1)
setcolor(4)
MAXY=getmaxy()
draw(280,280)/*左心*/
draw(370,280)/*右心*/
jian()
getch()
closegraph()
}
兄弟,你程序的for语句的变量递增是不是用得太不恰当了,应该说循环次数为纳樱慧整数类型,你把for(theta=0theta<2*3.14theta+=0.01)
此句先定义theta为整型再改为
for(theta=0theta<洞答2*314theta++)
另外你的程序风格我不太喜欢,有个很好的建议:用PUTPIXCEL和GETPIXCEL函数将计算得出的座标数组动态输出。另外建议你有空的话多上网“道”点国外颂含名家的C程序看看。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)