c语言表白浪漫烟花效果代码(简单的装x编程代码)

http://www.itjxue.com  2023-03-04 15:56  来源:未知  点击次数: 

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 "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语言编写的表白程序,要代码

#define IdYes 1002

#define IdNo 1003

#define IdStatic 1004

#define IdTimer 1005

#define Width 640

#define Height 480

#define Tick 2000

#includewindows.h

int x,y;

RECT rdesk;

HINSTANCE hinst;

HWND hyes,hno;

BOOL quit=FALSE;

LRESULT CALLBACK WndProc(HWND hwnd,UINT Message,WPARAM wParam,LPARAM lParam)

{

HDC hdc;

PAINTSTRUCT ps;

RECT rclient;

HBRUSH hbrbkgnd;

static COLORREF c;

static BYTE r,g,b;

switch(Message)

{

case WM_TIMER:

if(IdTimer==LOWORD(wParam))

{

r=(BYTE)(rand()%256);

g=(BYTE)(rand()%256);

b=(BYTE)(rand()%256);

c=RGB(r,g,b);

InvalidateRect(hwnd,NULL,TRUE);

UpdateWindow(hwnd);

}

break;

case WM_PAINT:

hdc=BeginPaint(hwnd,ps);

hbrbkgnd=CreateSolidBrush(c);

SelectObject(hdc,hbrbkgnd);

GetClientRect(hwnd,rclient);

FillRect(hdc,rclient,hbrbkgnd);

DeleteObject(hbrbkgnd);

EndPaint(hwnd,ps);

break;

case WM_COMMAND:

switch(LOWORD(wParam))

{

case IdYes:

quit=TRUE;

MessageBox(hwnd,TEXT("回答正确,太太太好了!"),TEXT("宝贝"),MB_ICONEXCLAMATION|MB_OK);

SendMessage(hwnd,WM_CLOSE,0,0);

break;

case IdNo:

MessageBox(hwnd,TEXT("回答错误哦,我很生气呢!"),TEXT("宝贝"),MB_ICONEXCLAMATION|MB_OK);

break;

}

break;

case WM_SIZE:

case WM_MOVE:

SetWindowPos(hwnd,HWND_TOPMOST,x,y,Width,Height,SWP_SHOWWINDOW);

break;

case WM_DESTROY:

PostQuitMessage(0);

break;

case WM_CLOSE:

if(quit)

{

KillTimer(hwnd,IdTimer);

DestroyWindow(hwnd);

}

break;

case WM_CREATE:

CreateWindow(TEXT("Static"),

TEXT("请回答:做我女朋友好吗?"),

WS_CHILD|WS_VISIBLE|SS_CENTER,

200,

200,

240,

20,

hwnd,

(HMENU)IdStatic,

hinst,

NULL

);

hyes=CreateWindow(TEXT("Button"),

TEXT("好"),

WS_CHILD|WS_VISIBLE|BS_CENTER,

270,

230,

45,

20,

hwnd,

(HMENU)IdYes,

hinst,

NULL

);

hno=CreateWindow(TEXT("Button"),

TEXT("不好"),

WS_CHILD|WS_VISIBLE|BS_CENTER,

325,

230,

45,

20,

hwnd,

(HMENU)IdNo,

hinst,

NULL

);

SetTimer(hwnd,IdTimer,Tick,NULL);

break;

default:

return DefWindowProc(hwnd,Message,wParam,lParam);

}

return 0;

}

int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nCmdShow)

{

WNDCLASSEX wc;

HWND hwnd;

MSG msg;

hinst=hInstance;

srand(time(NULL));

memset(wc,0,sizeof(wc));

wc.cbSize=sizeof(WNDCLASSEX);

wc.lpfnWndProc=WndProc;

wc.hInstance=hInstance;

wc.hCursor=LoadCursor(NULL,IDC_ARROW);

wc.hbrBackground=(HBRUSH)(COLOR_WINDOW+1);

wc.lpszClassName=TEXT("WindowClass");

wc.hIcon=LoadIcon(NULL,IDI_APPLICATION);

wc.hIconSm=LoadIcon(NULL,IDI_APPLICATION);

if(!RegisterClassEx(wc))

{

MessageBox(NULL,TEXT("窗口注册失败!"),TEXT("错误"),MB_ICONEXCLAMATION|MB_OK);

return 0;

}

GetWindowRect(GetDesktopWindow(),rdesk);

x=(rdesk.right-Width)/2;

y=(rdesk.bottom-Height)/2,

hwnd = CreateWindowEx(WS_EX_TOPMOST,

TEXT("WindowClass"),

TEXT("I Love You"),

WS_THICKFRAME|WS_VISIBLE,

x,

y,

Width,

Height,

NULL,NULL,hInstance,NULL);

if(NULL==hwnd)

{

MessageBox(NULL,TEXT("窗口创建失败!"),TEXT("错误!"),MB_ICONEXCLAMATION|MB_OK);

return 0;

}

while(GetMessage(msg,NULL,0,0)0)

{

TranslateMessage(msg);

DispatchMessage(msg);

}

return msg.wParam;

}

截图

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语言开发《浪漫流星雨》表白程序,源码来了

浪漫表白效果:

开发环境:Visual Studio 2019 + EasyX图形库插件即可

源码展示:

以上就是我们表白程序的源码了!最后祝大家都能和喜欢的人在一起哦~

我的C/C++编程学习基地,点击正在跳转「链接」即可加入,欢迎有问题的小伙伴一起进来学习交流嗷~

(责任编辑:IT教学网)

更多
上一篇:没有了

推荐其他营销文章