• 个人简介

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


    注:拿我头像乱抠图并不交版权费不得好死


    本人主页放置了a lot of代码,欢迎游玩!!! (最近有点忙,之后会持续更新的)


    也是终于更新了,这个代码是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

  • 通过的题目

  • 最近活动

题目标签

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