1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
{
# include<stdio.h>
# include<graphics.h>
# include<math.h>
# include<conio.h>
# definePI 3.1415926
//绘制心形线的函数
void cardioid( int x, int y, int a)
//x: x方向上的偏移量/
/y: y方向上的偏移量
//a: 缩放倍数
{
intx1, y1, x2, y2;
doubleangle = 0;
while(angle <= 2* PI)
{
x1 = a * ( 2* sin(angle) + sin( 2* angle)) + x;
y1 = a * ( 2* cos(angle) + cos( 2* angle)) + y;
angle += (PI / 180);
x2 = a * ( 2* sin(angle) + sin( 2* angle)) + x;
y2 = a * ( 2* cos(angle) + cos( 2* angle)) + y;
line(x1, y1, x2, y2);Sleep( 5);
}
}
int main( void)
{initgraph( 960, 540);
setlinecolor(RGB( 255, 0, 0));
cardioid( 480, 270, 50);
int ret = getch;
closegraph;
return 0;
}
}
1
2
3
4
{
printf("Hello World!");
return 0;
}

X2

X2

X^2^