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);
}
扩展资料
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;
}
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语言表白程序代码
用C语言编写一个程序相信爱的人表白。
电脑:华为MateBook14
系统:Windows10
软件:VC++
1、正确打开VC++,设置适合自己的字体大小及你想说的话。
2、编写程序:
#include stdio.hvoid main(){printf("*********************\n");printf("我是发自内心的爱你\n");printf("*********************\n");}。
3、点击“编译”,“连接”,“运行”,检验程序是否正确。