问题标题: 猜数字小游戏

0
0
已解决
汪艾辰
汪艾辰
高级光能
高级光能
#include<iostream>
#include<ctime>
#include<windows.h>
using namespace std;
int main(){
    cout<<"游戏加载中";
    for(int i=1;i<=6;i++){
        cout<<".";
        Sleep(1000);
    }
    system("cls");
    for(int i=1;i<=100;i++){
        cout<<i<<"%";
        Sleep(1);
        system("cls");
    }
    cout<<"游戏加载成功!";
    Sleep(1000);
    system("cls");
    long long MIN,MAX,a,hp=3,jc;
    cout<<"请输入数字范围(如:范围为1~20,则输入1空格20)\n";
    cin>>MIN>>MAX;
    srand((int)time(NULL));
    int ans=MIN+rand()%(MAX-MIN+1);
    Sleep(1000);
    system("cls");
    while(1){
        for(int i=1;i<=hp;i++){
            cout<<"HP:";
            for(int j=1;j<=hp+1-i;j++){
                cout<<"★";
            }
            cout<<"\n请输入一个("<<MIN<<"~"<<MAX<<")之间的数\n";
            cin>>a;
            if(a==0){
                system("cls");
                Sleep(1000);
                cout<<"恭喜你发现本游戏的彩蛋\n";
                system("pause");
                system("cls");
                cout<<" ╭╮\n";
                cout<<" /  \\ \n";
                cout<<"╰┈╯\n";
                system("pause");
                system("cls");
                long long MIN2=1,MAX2=5;
                srand((int)time(NULL));
                int ans2=MIN2+rand()%(MAX2-MIN2+1);
                Sleep(2000);
                if(ans2==3){
                    cout<<"    ╮\n";
                    cout<<"+10★╯\n";
                    cout<<" /  \\ \n";
                    cout<<"╰┈╯\n";
                    cout<<"你将获得额外生命值+10\n";
                    hp+=11;
                }
                if(ans2==1){
                    cout<<"    ╮\n";
                    cout<<"+15★╯\n";
                    cout<<" /  \\ \n";
                    cout<<"╰┈╯\n";
                    cout<<"你将获得额外生命值+15\n";
                hp+=16;
                }
                if(ans2==2){
                    cout<<"    ╮\n";
                    cout<<"+5★ ╯\n";
                    cout<<" /  \\ \n";
                    cout<<"╰┈╯\n";
                    cout<<"你将获得额外生命值+5\n";
                    hp+=6;
                }
                if(ans2==5){
                    cout<<"    ╮\n";
                    cout<<"+1★ ╯\n";
                    cout<<" /  \\ \n";
                    cout<<"╰┈╯\n";
                    cout<<"你将获得额外生命值+1\n";
                    hp+=2;
                }
                if(ans2==4){
                    cout<<"    ╮\n";
                    cout<<"-1★ ╯\n";
                    cout<<" /  \\ \n";
                    cout<<"╰┈╯\n";
                    cout<<"你的生命值将-1\n";
                }
                Sleep(2000);
                system("cls");
                continue;
            }
            if(a==ans&&i==1){
                cout<<"运气爆表o(* ̄ ︶  ̄*)o,一次就猜对了";
                break;
            }
            else if(a==ans){
                cout<<"恭喜你,猜对了!(*^▽^*)";
                break;
            }
            else if(a>ans&&i<hp){
                cout<<"你猜的太大了![○`Д′○]"<<endl;
                continue;
            }
            else if(a<ans&&i<hp){
                cout<<"你猜的太小了!(╬ ̄皿 ̄)=○"<<endl;
                continue;
            }
            else{
                cout<<"再接再厉! ̄ω ̄=\n";
            }
        }
        cout<<"是否继续游戏?继续请输入Y,否则输出N!(~~ ̄ ▽  ̄)~~";
        cin>>jc;
        if(jc!='Y'&&jc!='y'){
            break;
        }
        system("cls");
    }
    return 0;
}

 


0
0
0
曹博扬
曹博扬
初级天翼
初级天翼

这明显是老师讲的(我只上过一个这样的游戏,之后就去火箭班了,然后又去创新班了)

我要回答