返回列表 發帖
本帖最後由 許宸瑀 於 2022-3-26 11:30 編輯
  1. #include<iostream>
  2. #include<cstdlib>
  3. #include<ctime>
  4. using namespace std;
  5. int main()
  6. {
  7.     int n =1,blance=0;
  8.     re:
  9.       system("cls");
  10.     int a=0,b=0,c=0,d=0,r, option, buyin =0 ;   
  11.     cout<<"「好事成雙」賽馬場 第"<<n<<"局"<<endl;
  12.     cout<<"------------------------------------------------------------------------| 終點"<<endl;
  13.     cout<<"◆"<<endl;
  14.     cout<<"★"<<endl;
  15.     cout<<"▲"<<endl;
  16.     cout<<"●"<<endl;
  17.     cout<<endl;
  18.     cout<<"可用餘額:"<<blance<<"元"<<endl;
  19.     cout<<endl;
  20.     cout<<"(1)買入 (2)下注 (3)離開 請選擇:";
  21.     cin>>option;

  22.     if(option==1)
  23.     {
  24.         cout<<"買入:";
  25.         cin>>buyin;
  26.         blance += buyin;
  27.         goto re;
  28.     }
  29.    
  30.     system("pause");
  31.     system("cls");
  32.     srand(time(NULL));

  33.    
  34.     string words ="賽馬進行中";
  35.   
  36.     string name[4] = {"◆","★","▲","●"};
  37.    
  38.     int position =0;
  39.     while(a<=70 && b<=70 && c<=70 && d<=70)
  40.     {  
  41.       cout<<words<<endl;
  42.       cout<<"------------------------------------------------------------------------| 終點"<<endl;   

  43.       r = rand()%4+1;

  44.       switch(r)
  45.       {
  46.           case 1:
  47.                a++;
  48.                break;
  49.           case 2:
  50.                b++;
  51.                break;
  52.           case 3:
  53.                c++;
  54.                break;
  55.           case 4:
  56.                d++;
  57.                break;
  58.       }
  59.       
  60.       for(int i=0;i<=a;i++)
  61.       {
  62.           cout<<" ";
  63.       }
  64.       cout<<name[0]<<endl;
  65.       
  66.       for(int i=0;i<=b;i++)
  67.       {
  68.           cout<<" ";
  69.       }
  70.       cout<<name[1]<<endl;
  71.       
  72.       for(int i=0;i<=c;i++)
  73.       {
  74.           cout<<" ";
  75.       }
  76.       cout<<name[2]<<endl;
  77.       
  78.       for(int i=0;i<=d;i++)
  79.       {
  80.           cout<<" ";
  81.       }
  82.       cout<<name[3]<<endl;
  83.       
  84.    
  85.       if(a==70 || b==70 || c==70 || d==70)
  86.       {  
  87.          if(a==70)
  88.               position = 0;
  89.          if(b==70)
  90.               position =1;
  91.          if(c==70)
  92.               position =2;
  93.          if(d==70)
  94.               position =3;           
  95.          
  96.          words = "比賽結束!由"+name[position]+"先馳得點!";
  97.       }
  98.   
  99.       if(a==71 || b==71 || c==71 || d==71)
  100.       {               
  101.       }else{      
  102.         system("cls");
  103.       }
  104.       
  105.     }

  106.     n++;
  107.     system("pause");
  108.     system("cls");
  109.     goto re;
  110.     return 0;   
  111. }
複製代碼
  1. #include<iostream>
  2. #include<cstdlib>
  3. #include<ctime>
  4. using namespace std;
  5. int main()
  6. {
  7.     int n =1,blance=0;
  8.     re:
  9.    
  10.     int a=0,b=0,c=0,d=0,r, option, buyin =0 ;   
  11.     cout<<"「好事成雙」賽馬場 第"<<n<<"局"<<endl;
  12.     cout<<"------------------------------------------------------------------------| 終點"<<endl;
  13.     cout<<"◆"<<endl;
  14.     cout<<"★"<<endl;
  15.     cout<<"▲"<<endl;
  16.     cout<<"●"<<endl;
  17.     cout<<endl;
  18.     cout<<"可用餘額:"<<blance<<"元"<<endl;
  19.     cout<<endl;
  20.     cout<<"(1)買入 (2)下注 (3)離開 請選擇:";
  21.     cin>>option;

  22.     if(option==1)
  23.     {
  24.         cout<<"買入:";
  25.         cin>>buyin;
  26.         blance += buyin;
  27.         goto re;
  28.     }
  29.    
  30.     system("pause");
  31.     system("cls");
  32.     srand(time(NULL));

  33.    
  34.     string words ="賽馬進行中";
  35.   
  36.     string name[4] = {"◆","★","▲","●"};
  37.    
  38.     int position =0;
  39.     while(a<=70 && b<=70 && c<=70 && d<=70)
  40.     {  
  41.       cout<<words<<endl;
  42.       cout<<"------------------------------------------------------------------------| 終點"<<endl;   

  43.       r = rand()%4+1;

  44.       switch(r)
  45.       {
  46.           case 1:
  47.                a++;
  48.                break;
  49.           case 2:
  50.                b++;
  51.                break;
  52.           case 3:
  53.                c++;
  54.                break;
  55.           case 4:
  56.                d++;
  57.                break;
  58.       }
  59.       
  60.       for(int i=0;i<=a;i++)
  61.       {
  62.           cout<<" ";
  63.       }
  64.       cout<<name[0]<<endl;
  65.       
  66.       for(int i=0;i<=b;i++)
  67.       {
  68.           cout<<" ";
  69.       }
  70.       cout<<name[1]<<endl;
  71.       
  72.       for(int i=0;i<=c;i++)
  73.       {
  74.           cout<<" ";
  75.       }
  76.       cout<<name[2]<<endl;
  77.       
  78.       for(int i=0;i<=d;i++)
  79.       {
  80.           cout<<" ";
  81.       }
  82.       cout<<name[3]<<endl;
  83.       
  84.    
  85.       if(a==70 || b==70 || c==70 || d==70)
  86.       {  
  87.          if(a==70)
  88.               position = 0;
  89.          if(b==70)
  90.               position =1;
  91.          if(c==70)
  92.               position =2;
  93.          if(d==70)
  94.               position =3;           
  95.          
  96.          words = "比賽結束!由"+name[position]+"先馳得點!";
  97.       }
  98.   
  99.       if(a==71 || b==71 || c==71 || d==71)
  100.       {               
  101.       }else{      
  102.         system("cls");
  103.       }
  104.       
  105.     }

  106.     n++;
  107.     system("pause");
  108.     system("cls");
  109.     goto re;
  110.     return 0;   
  111. }
複製代碼

TOP

返回列表