四叶草

在图形输出窗口中动态绘制四叶草。

 

 

 1 #include <graphics.h>
 2 #include <math.h>
 3 #include <conio.h>
 4 #define PI 3.1415926535
 5 void main(void)
 6 {
 7     initgraph(640,480);
 8     setcolor(GREEN);
 9     setorigin(320,240);
10     double e;
11     int x1,y1,x2,y2;
12     for(double a=0;a<2*PI;a+=2*PI/720)
13     {
14         e=100*(1+sin(4*a));
15         x1=(int)(e*cos(a));
16         y1=(int)(e*sin(a));
17         x2=(int)(e*cos(a+PI/5));
18         y2=(int)(e*sin(a+PI/5));
19         line(x1,y1,x2,y2);
20         Sleep(20);
21     }
22     getch();
23     closegraph();
24 }

 

转载于:https://www.cnblogs.com/wangmengmeng/p/4616370.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值