C语言打烟花
❶ c语言放烟花代码
#include "stdlib.h"
#include "graphics.h"
#include "stdio.h"
#include "math.h"
#include "conio.h "
#define PI 3.1425926
main()
{
int gdriver=DETECT,gmode,errorcode;
int a[10],b[10],x,y,c,r,i,j,t;
double rad = 0.0;
/* initialize graphics and local variables */
initgraph(&gdriver , &gmode ,"");
/* read result of initialization */
errorcode = graphresult();
if (errorcode != grOk) /* an error occurred */
{
printf("Graphics error : %s/n",grapherrormsg(errorcode));
printf("Please any key to halt:");
getch();
exit(1); /* terminate with an error code */
}
randomize();
for(;!kbhit();)
{
x=rand()%500+100; /*随机中心坐标*/
y=rand()%300+100;
for(r = 0 ;r <= 8 ; r++ ) /*烟花的大小设定*/
{
for(i = 0,rad = 0.0 ; rad < 2*PI; rad += 0.78 ) /*设定坐标*/
{
a[i++] = x + (int)r *10* cos(rad);
b[ i ] = y + (int)r *10* sin(rad);
}
t = i;
for(i=1;i<t;i++)
{
c=rand()%13+1; /*各点的颜色随机*/
setcolor(c); /*功能:将当前图形屏幕的当前笔画颜色置为color.*/
circle(a[i],b[i],1);/* a[i],b[i] 为圆心 1 为半径 画圆 */
}
delay(10000);
delay(10000);
cleardevice();
函数名: cleardevice
功 能: 清除图形屏幕
用 法: void far cleardevice(void);
}
}
getch();
closegraph();
函数名: closegraph
功 能: 关闭图形系统
用 法: void far closegraph(void);
}
(1)C语言打烟花扩展阅读
C语言:表白显示(多彩小心心)
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#define I 20
#define R 340
#include <string.h>
int main()
{
char answer[10];
printf("遇到你 我才发现 曾经所有的条件 似乎都成了我等你的借口 ");
printf("我对你的感情已经决堤 所以 请允许我,从今往后映入你 明媚的眼 ");
printf("我 想和你 耳鬓厮磨,相濡以沫!");
printf("答应我吧! 输入yes,你可以看到我的真心 ");
scanf("%s", answer);
float y, x, z, f;
for (y = 1.5f; y > -1.5f; y -= 0.1f)
{
for (x = -1.5f; x < 1.5f; x += 0.05f)
{
z = x * x + y * y - 1;
f = z * z*z - x * x*y*y*y;
putchar(f <= 0.0f ? "*********"[(int)(f*-8.0f)] : ' ');
}
putchar(' ');
}
long time;
for (;;)
{
system("color a");
for (time = 0; time<99999999; time++);
system("color b");
for (time = 0; time<99999999; time++);
system("color c");
for (time = 0; time<99999999; time++);
system("color d");
for (time = 0; time<99999999; time++);
system("color e");
for (time = 0; time<99999999; time++);
system("color f");
for (time = 0; time<99999999; time++);
system("color 0");
for (time = 0; time<99999999; time++);
system("color 1");
for (time = 0; time<99999999; time++);
system("color 2");
for (time = 0; time<99999999; time++);
system("color 3");
for (time = 0; time<99999999; time++);
system("color 4");
for (time = 0; time<99999999; time++);
system("color 5");
for (time = 0; time<99999999; time++);
system("color 6");
for (time = 0; time<99999999; time++);
system("color 7");
for (time = 0; time<99999999; time++);
system("color 8");
for (time = 0; time<99999999; time++);
system("color 9");
}
getchar();
return 0;
}
❷ 请大家帮我用C语言程序设计一个动画是一个小孩走到鞭炮前放鞭炮,天空上有烟花,最好再有一栋房子。谢谢。
就是就是
这方面用c麻烦死了
还是学学flash吧
简单得多
有c的基础
actionscript也不难学
❸ 模拟烟花的程序,运行总出错,请c语言大师指点!!!
选项->目录->输出目录->不要设置和initgraph(&dr,&mode,"d:\\turboc2"); 一样就可以正常执行.
Options->Directories->Output Directory->不要设置和initgraph(&dr,&mode,"d:\\turboc2"); 一样就可以正常执行.
❹ C语言如何用代码打出星星,如下
既然你这么急,我还是答一下吧,原图没法输出,类似的可以实现,,你看哪个最像原图就写哪个吧:
图形1:
#include <stdio.h>
int main(void)
{
int i,j;
for(i=1;i<=7;i++)
{
for(j=7-i;j--;) printf(" ");
for(j=i;j--;) printf(" *");
printf(" ");
}
return 0;
}
❺ 怎么用C语言编程 用星形(’*’)打出一个春节的春字
需要先把“春”
生成点阵字模(一个二维数组,元素为0或者1),然后根据这个逐个读取,0输出空格,1输出*号
,
汉字点阵字模
生成工具
网上搜一个就可以了