devc++爱心粒子代码
时间: 2023-11-20 11:07:59 浏览: 236
以下是Dev-C++实现爱心粒子效果的代码,需要先配置EGE绘图库:
```c
#include <graphics.h>
#include <math.h>
#include <time.h>
#include <stdlib.h>
#define PI 3.14159265358979323846
int main()
{
initgraph(640, 480);
srand((unsigned)time(NULL));
int x, y, r, g, b, i;
double a, t;
for (i = 0; i < 1000; i++)
{
x = rand() % 640;
y = rand() % 480;
r = rand() % 256;
g = rand() % 256;
b = rand() % 256;
setlinecolor(RGB(r, g, b));
for (a = 0; a < 2 * PI; a += 0.001)
{
t = pow(sin(a), 3) + pow(cos(a), 3);
putpixel(x + 160 * t * t * sin(a), y - 130 * t * cos(a), RGB(r, g, b));
}
}
getch();
closegraph();
return 0;
}
```
阅读全文