c语言表白浪漫烟花效果代码复制(c语言烟花效果)
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;it;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);
}
初始化烟花参数
void Init( int i )
{
// 分别为:烟花中心到图片边缘的最远距离、烟花中心到图片左上角的距离 (x、y) 两个分量
int r[13] = { 120, 120, 155, 123, 130, 147, 138, 138, 130, 135, 140, 132, 155 };
int x[13] = { 120, 120, 110, 117, 110, 93, 102, 102, 110, 105, 100, 108, 110 };
int y[13] = { 120, 120, 85, 118, 120, 103, 105, 110, 110, 120, 120, 104, 85 };
/**** 初始化烟花 *****/
Fire[i].x = 0; // 烟花中心坐标
Fire[i].y = 0;
Fire[i].width = 240; // 图片宽
Fire[i].height = 240; // 图片高
Fire[i].max_r = r[i]; // 最大半径
Fire[i].cen_x = x[i]; // 中心距左上角距离
Fire[i].cen_y = y[i];
Fire[i].show = false; // 是否绽放
Fire[i].dt = 5; // 绽放时间间隔
Fire[i].t1 = timeGetTime();
Fire[i].r = 0; // 从 0 开始绽放
/**** 初始化烟花弹 *****/
Jet[i].x = -240; // 烟花弹左上角坐标
Jet[i].y = -240;
Jet[i].hx = -240; // 烟花弹发射最高点坐标
Jet[i].hy = -240;
Jet[i].height = 0; // 发射高度
Jet[i].t1 = timeGetTime();
Jet[i].dt = rand() % 10; // 发射速度时间间隔
Jet[i].n = 0; // 烟花弹闪烁图片下标
Jet[i].shoot = false; // 是否发射
}
c语言浪漫代码
#include stdio.h
int main()
{
int i, j, k, l, m;
char c = '*'; //ASCII码里面 3 就是一个字符小爱心
for (i = 1; i = 5; i++)
printf("\n"); //开头空出5行
for (i = 1; i = 4; i++)
{ //前3行中间有空隙分开来写
for (j = 1; j = 32 - 2 * i; j++)
printf(" "); //左边的空格,每下一行左边的空格比上一行少2个 //8*n-2*i
for (k = 1; k = 4 * i - 2; k++)
printf("%c", c); //输出左半部分字符小爱心
for (l = 1; l = 17 - 4 * i; l++)
printf(" "); //中间的空格,每下一行的空格比上一行少4个
for (m = 1; m = 4 * i - 2; m++)
printf("%c", c); //输出右半部分字符小爱心
printf("\n"); //每一行输出完毕换行
}
for (i = 1; i = 3; i++)
{ //下3行中间没有空格
for (j = 1; j = 22 + 1; j++)
printf(" "); //左边的空格 //8*(n-1)+1
for (k = 1; k = 31; k++)
printf("%c", c); //输出字符小爱心
printf("\n"); //每一行输出完毕换行
}
for (i = 7; i = 1; i--)
{ //下7行
for (j = 1; j = 38 - 2 * i; j++)
printf(" "); //左边的空格,每下一行左边的空格比上一行少2个//8*(n+1)-2*i
for (k = 1; k = 4 * i + 1; k++)
printf("%c", c); //每下一行的字符小爱心比上一行少4个(这个循环是i--)
printf("\n"); //每一行输出完毕换行
}
for (i = 1; i = 38; i++)
printf(" "); //最后一行左边的空格
printf("%c", c); //最后一个字符小爱心
for (i = 1; i = 5; i++)
printf("\n"); //最后空出5行
return 0;
}
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;it;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);
}
扩展资料
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("遇到你\n我才发现\n曾经所有的条件\n似乎都成了我等你的借口\n\n");
printf("我对你的感情已经决堤\n所以\n请允许我,从今往后映入你\n明媚的眼\n");
printf("我\n想和你\n耳鬓厮磨,相濡以沫!");
printf("答应我吧!\n输入yes,你可以看到我的真心\n");
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('\n');
}
long time;
for (;;)
{
system("color a");
for (time = 0; time99999999; time++);
system("color b");
for (time = 0; time99999999; time++);
system("color c");
for (time = 0; time99999999; time++);
system("color d");
for (time = 0; time99999999; time++);
system("color e");
for (time = 0; time99999999; time++);
system("color f");
for (time = 0; time99999999; time++);
system("color 0");
for (time = 0; time99999999; time++);
system("color 1");
for (time = 0; time99999999; time++);
system("color 2");
for (time = 0; time99999999; time++);
system("color 3");
for (time = 0; time99999999; time++);
system("color 4");
for (time = 0; time99999999; time++);
system("color 5");
for (time = 0; time99999999; time++);
system("color 6");
for (time = 0; time99999999; time++);
system("color 7");
for (time = 0; time99999999; time++);
system("color 8");
for (time = 0; time99999999; time++);
system("color 9");
}
getchar();
return 0;
}