请帮我写一个c语言的满屏烟花代码
时间: 2023-08-28 20:24:23 浏览: 74
好的,请参考以下代码:
```c
#include <graphics.h>
#include <stdlib.h>
#include <time.h>
int main()
{
int gd = DETECT, gm;
initgraph(&gd, &gm, "");
srand(time(NULL));
while (!kbhit())
{
int x = rand() % getmaxx();
int y = rand() % getmaxy();
int radius = rand() % 50 + 10;
int color = rand() % 15 + 1;
setfillstyle(SOLID_FILL, color);
setcolor(color);
fillellipse(x, y, radius, radius);
delay(100);
cleardevice();
}
closegraph();
return 0;
}
```
这段代码使用了 `graphics.h` 中的库函数和随机数生成函数 `rand()`,在屏幕上随机生成彩色的圆形,模拟出烟花爆炸的效果。你可以根据需要进行修改样式和延时时间。
相关问题
帮我写一个C语言的Hello world代码
你好!以下是C语言的Hello world代码:
#include <stdio.h>
int main() {
printf("Hello world!\n");
return ;
}
希望能对你有所帮助!
帮我写一个c语言代码
当然,我很乐意帮忙。
首先,你需要告诉我你想要实现的功能是什么。然后我会尽力用 C 语言为你写出代码。
例如,如果你想让程序输出 "Hello, World!",你可以使用下面的代码:
```
#include <stdio.h>
int main(void) {
printf("Hello, World!\n");
return 0;
}
```
这段代码使用了 `stdio.h` 头文件中的 `printf` 函数来输出字符串。 `main` 函数是程序的入口点,它会在程序启动时自动执行。
如果你有其他需求,请告诉我,我会尽力帮你写出合适的代码。