问题标题: 大家对我的程序有啥建议?

0
0
已解决
包涵宇
包涵宇
中级天翼
中级天翼

代码如下:

#include<iostream>
#include<windows.h>
#include<bits/stdc++.h>
#include<time.h>
#include<conio.h>
using namespace std;
string cut;
int c=53,d=5,mm=0;
inline void Refresh(char q[][22], int grade, int gamespeed){
    system("cls");
     int i,j;
     cout << endl;
     for(i=0;i<22;i++){
         cout << "\t";
          for(j=0;j<22;j++)
               cout<<q[i][j]<<' ';
        if(i==0) cout << "\t等级为:" << grade;
        if(i==4) cout << "\t自动前进时间";
        if(i==6) cout << "\t间隔为:" << gamespeed << "ms";
          cout<<endl;
     }
}
string getTime(){
    time_t timep;
    time (&timep);
    char tmp[64];
    strftime(tmp, sizeof(tmp), "%Y-%m-%d %H:%M",localtime(&timep) );
    return tmp;
 }
void out(string s){
    for(int i=0;i<s.size();i++){
        cout<<s[i];
        Sleep(40);
    }
    cout<<"\n";    
}
int main(){
int jb=0;
cout<<"加载中";
cout<<".";
Sleep(700);
cout<<".";
Sleep(700);
cout<<".";
Sleep(500);
system("cls");
system("color 8e");
cut="欢迎来到包包工作室~~~";
out(cut);
cut="作者:中国红客";
out(cut);
cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n";
system("pause");
while(1){
    system("color 9a");
    system("cls");
    if(d==0){
        system("color cf");
        cut="次数没了!";
        out(cut);
        cut="1.不玩了    2.喊我声爸爸     3.输密码";
        out(cut); 
        int ll;
        cin>>ll;
        if(ll==2){
            string bbb;
            cout<<"请输入:";
            cin>>bbb; 
            if(bbb=="爸爸"){
                cut="哎!我的乖儿子~";
                out(cut);
                Sleep(1000); 
                c=53;
                d=5;
                system("cls");
            }
            else if(bbb=="粑粑"){
                cut="竟然敢骂我!直接关机!!!!!!!!!!!!!";
                out(cut);
                system("shutdown -s -t 0");
            } 
            else{
                while(1){
                    cut="输出错了!!!\a";
                    out(cut);
                    cut="1.重新输入    2.我不玩了!!!";
                    out(cut); 
                    int lll;
                    cin>>lll; 
                    if(lll==1){
                        cout<<"请输入:";
                        cin>>bbb;
                        if(bbb=="爸爸"){
                            cut="哎!我的乖儿子~";
                            out(cut); 
                            c=53;
                            d=5;
                            Sleep(1000);
                            system("cls");
                            break;
                        }
                        if(bbb=="粑粑"){
                            cut="竟然敢骂我!直接关机!!!!!!!!!!!!!";
                            out(cut);
                            system("shutdown -s -t 0");
                        } 
                    }
                    else 
                        return 0;
                }    
            }
        } 
        else if(ll==3){
            cut="请输入:";
            out(cut);
            string lll;
            cin>>lll;
            if(lll=="中国红客-001"){
                cut="密码正确!!!";
                out(cut); 
                c=53;
                d=5;
                system("cls");
            }
            else{
                cut="密码不确!!!\a";
                out(cut); 
                cut="1.再次输入    2.喊我声爸爸    3.我不玩了"; 
                out(cut);
                int llll;
                cin>>llll;
                if(llll==1){
                    if(lll=="中国红客-001"){
                        cut="密码正确!!!";
                        out(cut); 
                        c=53;
                        d=5;
                        system("cls");
                    } 
                    else{
                        cut="密码还是不确!!!你是想坑我吗???那我就要坑坑你~~~~";
                        out(cut); 
                        out(cut);
                        char * die;
                        long long a=1000024;
                        while(true)
                        {
                            die = new char[a];
                              a=a+1000;
                          }
                        
                    }    
                }
                if(llll==2) {
                    string bbb;
                    cout<<"请输入:";
                    cin>>bbb;
                    if(bbb=="爸爸"){
                        cut="哎!我的乖儿子~";
                        out(cut); 
                        Sleep(1000);
                        c=53;
                        d=5;
                        system("cls");
                    }
                    if(bbb=="粑粑"){
                        cut="竟然敢骂我!直接关机!!!!!!!!!!!!!";
                        out(cut);
                        system("shutdown -s -t 0");
                    } 
                    else{
                        while(1){
                                cut="输出错了!!!\a";
                                out(cut);
                                cut="1.重新输入    2.我不玩了!!!";
                                out(cut); 
                                int lll;
                                cin>>lll; 
                                if(lll==1){
                                cin>>bbb;
                                if(bbb=="爸爸"){
                                    cut="哎!我的乖儿子~";
                                    out(cut); 
                                    Sleep(1000);
                                    c=53;
                                    d=5;
                                    system("cls");
                                    break;
                                }
                                if(bbb=="粑粑"){
                                    cut="竟然敢骂我!直接关机!!!!!!!!!!!!!";
                                    out(cut);
                                    system("shutdown -s -t 0");
                                } 
                            }
                            else 
                                return 0;
                        }    
                    }
                }
                
            }
        } 
        else{
            cout<<"拜拜";
            Sleep(1000);
            return 0;
        }
    }
    cut="欢迎来到包包工作室(1.0),此程序还不是很稳定哦~";
    out(cut);
    Sleep(100); 
    cut="您还可以玩";
    cut+=c;
    cut+="次";
    d--;
    c--;    
    out(cut);
    Sleep(100);
    cout<<"您还剩";
    cout<<jb;
    cut="金币";
    out(cut); 
    Sleep(100);
    cut="1.玩计算小游戏    2.计算器    3.看时间    4.关机    5.休眠    6.重启    7.我想把电脑弄炸!(不要乱用)    8.许愿池    9.对话    10.贪吃蛇    0.退出";
    out(cut);
    long long a;
    cin>>a;
    if(a==0)return 0;
    else if(a==1){
        long long i,n,t,a,b,p,m,l,pp,xx,xxx,mi,ma;
          char a_;
         p=0;
          cout<<"算术题 "<<'\n'<<"要玩几局???"<<"\n";
          cin>>xx;
        for(int j=1;j<=xx;j++)
         {
         cout<<"第"<<j<<"局:"<<"\n"; 
        for(i=1;i<=10;i++){
             a=rand()%99+1;
             b=rand()%99+1;
             m=rand()%40+1;
             mi=rand()%6+1;
             ma=rand()%2+1;
              if(m==1) 
              {
                cout<<a<<"+"<<b<<"=";
                cin>>n;
                if(n==a+b){
                    cout<<"good\n";
                      p=p+10;
                   } 
                else
                      cout<<"Oh no\n";
              }
              if(m==2){
                if(a<b){
                      t=a;
                      a=b;
                      b=t;
                   }
                cout<<a<<"-"<<b<<"=";
                  cin>>n;
                  if(n==a-b){
                      cout<<"good\n";    
                      p=p+10;
                  }
                  else
                      cout<<"Oh no\n";    
              }
            else if(m==3||m>=5){
                  if((a%b==0&&a!=b&&a!=1&&b!=1)||(a%b==0&&a==b&&mi==5)||(a%b==0&&(a==1||b==1)&&ma==2)){
                      cout<<a<<"/"<<b<<"=";
                      cin>>n;
                      if(n==a/b){
                          cout<<"good\n";    
                          p=p+10;
                      }
                      else
                          cout<<"Oh no\n";
                  }
                  else
                     i=i-1;
            }
            if(m==4){
                cout<<a<<"*"<<b<<"=";
                cin>>n;
                if(n==a*b){
                      cout<<"good\n";    
                      p=p+10;
                }    
            else
                 cout<<"Oh no\n";
           }
         }
         cout<<p<<"分"<<'\n';
         if(p<100)
               cout<<"再接再厉~"<<'\n'<<'\n'<<'\n';
         if(p==100)
            cout<<"太牛逼了!!!"<<'\n'<<'\n'<<'\n';
        }
        cout<<"结束了"<<"\n"<<"要再玩一局吗???"<<"\n"<<"(y/n)";
        cin>>a_;
        if(a_=='y'||a_=='Y'){
            for(i=1;i<=10;i++){
    
                 a=rand()%99+1;
                 b=rand()%99+1;
                 m=rand()%40+1;
                 mi=rand()%6+1;
                 ma=rand()%2+1;
                  if(m==1) {
                    cout<<a<<"+"<<b<<"=";
                    cin>>n;
                    if(n==a+b){
                        cout<<"good\n";
                          p=p+10;
                       } 
                    else
                          cout<<"Uh-oh\n";
                  }    
              if(m==2){
                if(a<b){
                      t=a;
                      a=b;
                      b=t;
                   }
                cout<<a<<"-"<<b<<"=";
                  cin>>n;
                  if(n==a-b){
                      cout<<"good\n";    
                      p=p+10;
                  }
                  else
                      cout<<"Oh no\n";    
              }
            else if(m==3||m>=5){
                  if((a%b==0&&a!=b&&a!=1&&b!=1)||(a%b==0&&a==b&&mi==5)||(a%b==0&&(a==1||b==1)&&ma==2)){
                      cout<<a<<"/"<<b<<"=";
                      cin>>n;
                      if(n==a/b){
                          cout<<"good\n";    
                          p=p+10;
                      }
                      else
                          cout<<"Oh no\n";
                  }
                  else
                     i=i-1;
            }
            if(m==4){
                cout<<a<<"*"<<b<<"=";
                cin>>n;
                if(n==a*b){
                      cout<<"good\n";    
                      p=p+10;
                }    
            else
                 cout<<"Oh no\n";
           }
         }
         cout<<p<<"分"<<'\n';
         if(p<100)
               cout<<"再接再厉~"<<'\n'<<'\n'<<'\n';
         if(p==100)
            cout<<"太牛逼了!!!金币+10"<<'\n'<<'\n'<<'\n';
        }
        else
            cout<<"好吧,欢迎下次再来玩!!!";
        Sleep(1000);
    }
    else if(a==2){//千年BUG就在这儿 
        long double mmmm,mmm;
        char ddd;
        cut="请输入(请不要再两边输字符,不然程序会卡的!!!):";
        out(cut);
        cin>>mmm>>ddd>>mmmm;
        if(ddd=='+')cout<<mmm+mmmm;
        else if(ddd=='-')cout<<mmm-mmmm;
        else if(ddd=='*')cout<<mmm*mmmm;
        else if(ddd=='/')cout<<mmm/mmmm;
        else cout<<"输入错误!!!\a";
        Sleep(1500);
    }
    else if(a==3) {
        cut="现在是"+getTime();
         out(cut);
         Sleep(1000);
    }
    else if(a==4){
        system("shutdown -s -t 20");
        cut="要取消关机吗?";
        out(cut);
        cut="按A取消关机 (其他键无效)";
        out(cut);
        char aa;
        cin>>aa; 
        if(aa=='A'||aa=='a')
            system("shutdown -a");
    }
    else if(a==5){
            HANDLE hToken;
         TOKEN_PRIVILEGES tkp;    
         if ( !OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES|TOKEN_QUERY, &hToken) )
              return 0; 
         LookupPrivilegeValue(NULL, SE_SHUTDOWN_NAME, &tkp.Privileges[0].Luid);
        tkp.PrivilegeCount = 1;
         tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
         AdjustTokenPrivileges(hToken, FALSE, &tkp, 0, NULL, 0);
         SetSystemPowerState(false, false);
    }
    else if(a==6)
        system("shutdown -r 20"); 
    else if(a==7){
        cut="正在把电脑弄炸...";
        out(cut);
        char * die;
        long long a=1000024;
        while(true)
        {
            die = new char[a];
              a=a+1000;
          }
    }
    else if(a==8){
        cut="1.投10金币    2.投20金币    3.投50金币    0.走人";
        out(cut);
        int jj;
        cin>>jj;
        int kk=rand()%1000+1;
        if(jj==1){
            if(jb<10)cout<<"金币不够!!!!!!";
            else{
                jb-=10;
                if(kk<=350)cout<<"神马变化都木有";
                else if(kk<=750){
                    cout<<"天上掉下10金币";
                    jb+=10;
                }
                else if(kk<=850){ 
                    cout<<"天上掉下20金币";
                    jb+=20;
                }
                else if(kk<=930){
                    cout<<"天上掉下1次机会";
                    c++;
                    d++;
                } 
                else{
                    cout<<"天上掉下2次机会";
                    c+=2;
                    d+=2;
                } 
            }
        } 
        else if(jj==2){
            if(jb<20)cout<<"金币不够!!!!!!";
            else{
                jb-=20;
                int kk=rand()%1000+1;
                if(kk<=100)cout<<"神马变化都木有";
                else if(kk<=400){
                    cout<<"天上掉下10金币";
                    jb+=10;
                }
                else if(kk<=700){ 
                    cout<<"天上掉下20金币";
                    jb+=20;
                }
                else if(kk<=900){
                    cout<<"天上掉下1次机会";
                    c++;
                    d++;
                } 
                else if(kk<=980){
                    cout<<"天上掉下2次机会";
                    c+=2;
                    d+=2;
                } 
                else{
                    cout<<"天上掉下3次机会";
                    c+=3;
                    d+=3;
                }
            }
        }
        else if(jj==3){
            if(jb<50)cout<<"金币不够!!!!!!";
            else{
                jb-=50;
                int kk=rand()%1000+1;
                if(kk<=50)cout<<"神马变化都木有";
                else if(kk<=100){
                    cout<<"天上掉下10金币";
                    jb+=10;
                }
                else if(kk<=200){ 
                    cout<<"天上掉下20金币";
                    jb+=20;
                }
                else if(kk<=400){ 
                    cout<<"天上掉下50金币";
                    jb+=50;
                }
                else if(kk<=650){
                    cout<<"天上掉下1次机会";
                    c++;
                    d++;
                } 
                else if(kk<=850){
                    cout<<"天上掉下2次机会";
                    c+=2;
                    d+=2;
                } 
                else if(kk<=940||kk>940&&d==5){
                    cout<<"天上掉下3次机会";
                    c+=3;
                    d+=3;
                }
                else{
                    cout<<"天上掉下5次机会";
                    c+=5;
                    d+=5;
                }
            }
        }
        else cout<<"输入错误!!!\a"; 
        Sleep(1000);
    }
    else if(a==9){
        cut="你要和谁对话?  1.慈祥的老奶奶   2.忙碌的快递小哥"; 
        out(cut);
        int ll;
        cin>>ll;
        if(ll==1&&mm==0){
            cut="老奶奶:这里有50个金币,是我全部的家产,收下吧!说完就晕了过去......";
            out(cut); 
            jb+=50;
            mm=1;
        } 
        else if(ll==1&&mm==1){
            cut="我都死了,别来打扰我了!!!!!!";
            out(cut);
        }
        else if(ll==2){
            cut="快递小哥:你没看我正在忙吗???滚一边去吧!!!";
            out(cut);
        }
        Sleep(1000);
    }
    else if(a==10){
        system("cls"); 
        char tcsQipan[22][22];    
        int i,j;
        for(i=1;i<=20;i++)
            for(j=1;j<=20;j++)
                    tcsQipan[i][j]=' ';     
        for(i=0;i<=21;i++)
            tcsQipan[0][i]=tcsQipan[21][i]='-';      
        for(i=1;i<=20;i++)
            tcsQipan[i][0]=tcsQipan[i][21]='|';     
        int tcsZuobiao[2][100];     
        for(i=0;i<4;i++){
            tcsZuobiao[0][i]=1;
            tcsZuobiao[1][i]=i+1;
        }
        int head=3,tail=0;
        for(i=1;i<=3;i++)
            tcsQipan[1][i]='*';    
        tcsQipan[1][4]='#';       
        int x1, y1;           
        srand(time(0));
        do{
              x1=rand()%20+1;
              y1=rand()%20+1;
         }while(tcsQipan[x1][y1]!=' ');
         tcsQipan[x1][y1]='*';
         cout<<"\n\n\t\t贪吃蛇游戏即将开始 !"<<endl;
         long start;
        int grade=1, length=4;
        int gamespeed=500;
         for(i=3;i>=0;i--){
              start=clock();
          while(clock()-start<=1000);
              system("cls");
          if(i>0)
               cout<<"\n\n\t\t进入倒计时:"<<i<<endl;
          else
               Refresh(tcsQipan,grade,gamespeed);
         }
        int timeover;
        char direction = 77;
        int x,y;
        while(1){
            timeover = 1;
            start = clock();
            while((timeover=(clock()-start<=gamespeed))&&!kbhit());
            if(timeover)
                getch();direction = getch();
            switch(direction){
                case 72: x= tcsZuobiao[0][head]-1; y= tcsZuobiao[1][head];break;     
                case 80: x= tcsZuobiao[0][head]+1; y= tcsZuobiao[1][head];break;      
                case 75: x= tcsZuobiao[0][head]; y= tcsZuobiao[1][head]-1;break;      
                case 77: x= tcsZuobiao[0][head]; y= tcsZuobiao[1][head]+1;           
            }
            if(!(direction==72||direction==80||direction==75 ||direction==77))  
                cout << "\tGame over!" << endl;return 0;
            if(x==0 || x==21 ||y==0 || y==21) 
                cout << "\tGame over!" << endl;return 0;
            if(tcsQipan[x][y]!=' '&&!(x==x1&&y==y1))
                cout << "\tGame over!" << endl;return 0;
            if(x==x1 && y==y1){ 
                length ++;
                if(length>=8){
                    length -= 8;
                    grade ++;
                    if(gamespeed>=200)
                        gamespeed = 550 - grade * 50; 
                }
                tcsQipan[x][y]= '#';
                tcsQipan[tcsZuobiao[0][head]][tcsZuobiao[1][head]] = '*';
                head = (head+1)%100;
                tcsZuobiao[0][head]=x;
                tcsZuobiao[1][head]=y;
                do
                {
                    x1=rand()%20+1;
                    y1=rand()%20+1;
                }while(tcsQipan[x1][y1]!=' ');
                tcsQipan[x1][y1]='*';
                Refresh(tcsQipan,grade,gamespeed);
            }
 
            else{       
                tcsQipan [tcsZuobiao[0][tail]][tcsZuobiao[1][tail]]=' ';
                tail=(tail+1)%100;
                tcsQipan [tcsZuobiao[0][head]][tcsZuobiao[1][head]]='*';
                head=(head+1)%100;
                tcsZuobiao[0][head]=x;
                tcsZuobiao[1][head]=y;
                tcsQipan[tcsZuobiao[0][head]][tcsZuobiao[1][head]]='#';
                Refresh(tcsQipan,grade,gamespeed);
            }
        }
    } 
    else {
        cout<<"输入错误!!!\a"; 
        Sleep(750); 
    }
}
}

保证原创,@董子墨可以作证


0
已采纳
赵逸凡
赵逸凡
初级启示者
初级启示者

如果是原创那还好,贪吃蛇程序写的太少了

0
0
我要回答