求C语言编写的表白程序,要代码

求C语言编写的表白程序,要代码,第1张

#define IdYes 1002

#define IdNo 1003

#define IdStatic 1004

#define IdTimer 1005

#define Width 640

#define Height 480

#define Tick 2000

#include<windowsh>

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));

wccbSize=sizeof(WNDCLASSEX);

wclpfnWndProc=WndProc;

wchInstance=hInstance;

wchCursor=LoadCursor(NULL,IDC_ARROW);

wchbrBackground=(HBRUSH)(COLOR_WINDOW+1);

wclpszClassName=TEXT("WindowClass");

wchIcon=LoadIcon(NULL,IDI_APPLICATION);

wchIconSm=LoadIcon(NULL,IDI_APPLICATION);

if(!RegisterClassEx(&wc))

{

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

return 0;

}

GetWindowRect(GetDesktopWindow(),&rdesk);

x=(rdeskright-Width)/2;

y=(rdeskbottom-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 msgwParam;

}

截图

1、浏览器标签法

这个先用不到代码,但却十分简单实用的,首先早一步到办公室,或者趁表白对象不注意的时候在她的电脑上安装chrome浏览器,设置成默认的浏览器,把各项的同步功能打开就可以了。然后选择一个合适的时机,在你的电脑上登录账号,然后标签栏添加你想说的话,例如下图这样:

然后标签就自动同步到表白对象的浏览器上了。

2、两个按键组合成I LOVE U

这个简单的功能是利用的网页查找的功能,在网页中复制下这段文字,

然后crtrl+f,在输入框中输入9,然后回车,看下效果:

3、Python表白代码

心型和圆形椭圆的代码类似,都是由X,Y上的点构成的曲线,确定出一个表达式expression,然后就是两个for循环(for y in range;for x in range),然后逐行逐列的开始就行了。

当然有点太单调,我们可以这样操作一下,让他动起来,像这样

print('\n'join([''join([('Love'[(x-y) % len('Love')] if ((x005)2+(y01)2-1)3-(x005)2(y01)3 <= 0 else ' ') for x in range(-30, 30)]) for y in range(30, -30, -1)]))

当然还能替换表情,这个代码就不放了,需要的直接跟我要就行。

4、炫酷一点的

C语言诠释爱——为TA写下心中情,生成程序传给TA,TA点开程序就懂你。

这个开始的时候会展示出表白对象的名字,接着就是最重要的烟花部分,为了让烟花显得更加真实,需要附加重力效果和空气阻力效果,源代码图如下

如果需要源码的留下邮乡就可以了。

5、恶搞一点的

这个适合关系已经不错的那种了,看看效果

源码直接发

#include<iostreamh>

#include<stdioh>

#include<ctypeh>

struct ca {

char c;

ca next;

};

void InitList(ca L) {

cout<<"输入一页文字(以#结束): "<<endl;

while((L->c = getchar()) != '#') {

L->next = new ca;

L = L->next;

}

L->next = NULL;

}

void StrNo(ca L) {

int n = 0;

char s[80], q;

ca p;

cout<<"输入一字符串: ";

cin>>s;

while(L->next) {

for (p = L, q = s; q != '\0' && p->next; p = p->next, q++)

if (p->c != q) break;

if (q == '\0') n++;

L = L->next;

}

cout<<"字符串 "<<s<<" 出现 "<<n<<" 次\n";

}

ca DelStr(ca L) {

ca H = L;

char s[80], q;

ca p;

cout<<"输入该子串: ";

cin>>s;

if (H->c == s) {

for (p = H->next, q = s+1; q != '\0' && p->next; p = p->next, q++)

if (p->c != q) break;

if (q == '\0') H = p;

}

while(L->next) {

for (p = L->next, q = s; q != '\0' && p->next; p = p->next, q++)

if (p->c != q) break;

if (q == '\0') L->next = p;

else L = L->next;

}

return H;

}

void print1(ca L) {

while(L->next) {

cout<<L->c;

L = L->next;

}

cout<<endl;

}

void print2(ca L, int &p1, int &p2, int &p3, int &n) {

n = p1 = p2 = p3 = 0;

for( ; L->next; L = L->next, n++)

if(isalpha(L->c)) p1++;

else if(isdigit(L->c)) p2++;

else if(L->c == ' ') p3++;

else if(L->c == '\n') n--;

cout<<"\n全部字母数: "<<p1;

cout<<"\n数字个数: "<<p2;

cout<<"\n空格个数: "<<p3;

cout<<"\n文章总字数: "<<n<<endl;

}

void main() {

ca L = new ca;

int p1, p2, p3, n, c;

InitList(L);

do {cout<<"\n0:退出\n"

"1:统计中英文字母和空格数以及整篇文章总字数\n"

"2:统计某一字符串在文章中出现次数\n"

"3:删除某一子串\n"

"4:分行输出用户输入的各行字符\n";

cin>>c;

switch(c) {

case 1:print2(L, p1, p2, p3, n);break;

case 2:StrNo(L);break;

case 3:DelStr(L);

case 4:print1(L);

}

}while(c);

程序员的表白代码

第一条语言:Java代码翻译:直到死之前,每天爱你多一点代码:while(lifeend){love++;}

第二条语言:C语言代码翻译:IcannotsayHellototheWorldwithoutu代码:#incldestdiohintmain(){printf(HelloWorldn);retrn0;}//IcannotsayHellototheWorldwithoutu

第三条语言:python代码翻译:山无陵,江水为竭,冬雷震震,夏雨雪,天地合,乃敢与君绝!代码:if(mountainarris==None):if(riverwater==None):if(winterthunder==True):if(summersnow==True):if(skyheight==groundheight):iwithyou=Falseelse:iwithyou=True

第四条语言:Erlang代码代码翻译:深圳相遇,至死不渝代码:-module(you_and_me)-export([start/1])-record(person,{name,address,status})start(Name)-one_world(Name)one_world(Name)keep_to_love_you(Person)say_goodbye(Person)-io:format(~p:seeyounextworld!~n,[Person#personname])see_you_next_world(Name)-one_world(Name)

第五条语言:Java语言代码翻译:爱你到天荒地老代码:while(!worlddestroy){Systemoutprintln(iloveyou);}

欢迎分享,转载请注明来源:表白网

原文地址:https://h5.hunlipic.com/biaobai/2863636.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2024-01-17
下一篇2024-01-17

发表评论

登录后才能评论

评论列表(0条)

    保存