返回列表 發帖
  1. #include<iostream>
  2. #include<cstdlib>
  3. #include<ctime>
  4. using namespace std;
  5. int main()
  6. {
  7.    
  8.    int n=1 blance=0;
  9.     re:
  10.            system("cls");
  11.    int a=0,b=0,c=0,d=0,r,opition,buyin=0,bet,horse;
  12.   cout<<"賽馬場 第"<<n<<"局"<<endl;
  13.   cout<<"-----------------------------------------------------------------終點"<<endl;  
  14.    cout<<"Ⅰ"<<endl;
  15.    cout<<"Ⅱ"<<endl;
  16.    cout<<"Ⅲ"<<endl;
  17.    cout<<"Ⅳ"<<endl;
  18.    cout<<endl;
  19.    cout<<"可用餘額"<<blance<<endl;
  20.    cout<<endl;
  21.    cout<<"(1)買入 (2)下注 (3)離開 請選擇:";
  22.    cin>>opition;
  23.     if(option==1)
  24.     {
  25.         cout<<"買入:";
  26.         cin>>buyin;
  27.         blance += buyin;
  28.         goto re;
  29.     }else if(option==2)
  30.     {
  31.           cout<<"請下注:";
  32.           cin>>bet;
  33.           if(bet>blance)
  34.           {
  35.                cout<<"你餘額不足"         
  36.    system("pause");
  37.    system("cls");  
  38.    srand(time(NULL));
  39.    
  40.    
  41.    int a=0,b=0,c=0,d=0,r,opition,buyin;
  42.    string words ="賽馬進行中";
  43.    string name[4]={"Ⅰ","Ⅱ","Ⅲ","Ⅳ"};
  44.    while(a<=70 && b<=70 && c<=70 && d<=70)
  45.    {
  46.                 cout<<words<<endl;
  47.       cout<<"------------------------------------------------------------------------| 終點"<<endl;   
  48.      r=rand()%4+1;
  49.      switch(r)
  50.      {     
  51.            case 1:      
  52.               a++;           
  53.               break;
  54.            case 2:      
  55.               b++;           
  56.               break;
  57.            case 3:      
  58.               c++;           
  59.               break;      
  60.            case 4:      
  61.               d++;           
  62.               break;   
  63.      }
  64.       for(int i=0;i<=a;i++)
  65.       {
  66.           cout<<" ";
  67.       }
  68.        cout<<name[0]<<endl;
  69.      
  70.        for(int i=0;i<=b;i++)
  71.       {
  72.           cout<<" ";
  73.       }
  74.        cout<<name[1]<<endl;
  75.       
  76.        for(int i=0;i<=c;i++)
  77.       {
  78.           cout<<" ";
  79.       }
  80.        cout<<name[2]<<endl;
  81.       
  82.        for(int i=0;i<=d;i++)
  83.       {
  84.           cout<<" ";
  85.       }
  86.        cout<<name[3]<<endl;
  87.       
  88.        if(a==70 || b==70 || c==70 || d==70)
  89.        {
  90.            int position;     
  91.            if(a==70)
  92.               position = 0;
  93.          if(b==70)
  94.               position =1;
  95.          if(c==70)
  96.               position =2;
  97.          if(d==70)
  98.               position =3;           
  99.            words = "比賽結束,由"+name[position]+"奪魁";     
  100.        }
  101.        if(a==71 || b==71 || c==71 || d==71)
  102.        {
  103.        }else{
  104.              system("cls");         
  105.        }   
  106.                      
  107.    }
  108.   n++;
  109. system("pause");
  110. system("cls");
  111. goto re;   
  112. return 0;   
  113. }
複製代碼

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. #include<ctime>
  4. using namespace std;
  5. int main()
  6. {
  7.    
  8.    int n=1,blance=0;   
  9.    re:
  10.         system("cls");
  11.         int a=0,b=0,c=0,d=0,r,opition,buyin,bet,horse;
  12.        string words ="賽馬進行中";
  13.    string name[4]={"Ⅰ","Ⅱ","Ⅲ","Ⅳ"};
  14.         int position =0;
  15.   cout<<"賽馬場 第"<<n<<"局"<<endl;
  16.   cout<<"-----------------------------------------------------------------終點"<<endl;  
  17.    cout<<"Ⅰ"<<endl;
  18.    cout<<"Ⅱ"<<endl;
  19.    cout<<"Ⅲ"<<endl;
  20.    cout<<"Ⅳ"<<endl;
  21.    cout<<endl;
  22.    cout<<"可用餘額"<<blance<<endl;
  23.    cout<<endl;
  24.    cout<<"(1)買入 (2)下注 (3)離開 請選擇:";
  25.    cin>>opition;
  26.     if(opition==1)
  27.     {
  28.         cout<<"買入:";
  29.         cin>>buyin;
  30.         blance += buyin;
  31.         goto re;
  32.     }else if(opition==2)
  33.     {
  34.           cout<<"下注金額:";
  35.           cin>>bet;
  36.           if(bet>blance)
  37.           {
  38.           cout<<"餘額不足 請重新下注"<<endl;
  39.           system("pause");
  40.           goto re;
  41.           }else if(bet>0 && blance>=bet)
  42.           {
  43.              cout<<"請選擇 (1)Ⅰ (2)Ⅱ (3)Ⅲ (4)Ⅳ"<<endl;
  44.              cin>>horse;
  45.              blance-=bet;
  46.              cout<<"即將開始賽馬"<<endl;
  47.             }else   
  48.             {
  49.                    cout<<"輸入錯誤 請重新輸入"<<endl;
  50.                    system("pause");
  51.                    goto re;
  52.             }
  53.                      
  54.        }else
  55.        {            
  56.          goto end;
  57.        }
  58.                  
  59.    system("pause");
  60.    system("cls");  
  61.    srand(time(NULL));
  62.    
  63.    
  64.    
  65.    while(a<=70 && b<=70 && c<=70 && d<=70)
  66.    {
  67.                 cout<<words<<endl;
  68.       cout<<"------------------------------------------------------------------------| 終點"<<endl;   
  69.      r=rand()%4+1;
  70.      switch(r)
  71.      {     
  72.            case 1:      
  73.               a++;           
  74.               break;
  75.            case 2:      
  76.               b++;           
  77.               break;
  78.            case 3:      
  79.               c++;           
  80.               break;      
  81.            case 4:      
  82.               d++;           
  83.               break;   
  84.      }
  85.       for(int i=0;i<=a;i++)
  86.       {
  87.           cout<<" ";
  88.       }
  89.        cout<<name[0]<<endl;
  90.      
  91.        for(int i=0;i<=b;i++)
  92.       {
  93.           cout<<" ";
  94.       }
  95.        cout<<name[1]<<endl;
  96.       
  97.        for(int i=0;i<=c;i++)
  98.       {
  99.           cout<<" ";
  100.       }
  101.        cout<<name[2]<<endl;
  102.       
  103.        for(int i=0;i<=d;i++)
  104.       {
  105.           cout<<" ";
  106.       }
  107.        cout<<name[3]<<endl;
  108.       
  109.        if(a==70 || b==70 || c==70 || d==70)
  110.        {
  111.            int position;     
  112.            if(a==70)
  113.               position = 0;
  114.          if(b==70)
  115.               position =1;
  116.          if(c==70)
  117.               position =2;
  118.          if(d==70)
  119.               position =3;           
  120.            words = "比賽結束,由"+name[position]+"奪魁";     
  121.        }
  122.        if(a==71 || b==71 || c==71 || d==71)
  123.        {
  124.        }else{
  125.              system("cls");         
  126.        }   
  127.                      
  128.    }
  129.   n++;
  130.     system("pause");
  131.     goto re;     
  132.     end:
  133.     system("pause");  
  134.     return 0;
  135. }
複製代碼

TOP

返回列表