返回列表 發帖
  1. #include<iostream>
  2. #include<cstdlib>
  3. #include<ctime>
  4. using namespace std;
  5. int main()
  6. {
  7.     int t=0,z=0;
  8.     re:
  9.     system("cls");  
  10.     t++;
  11.     int a=0,b=0,c=0,d=0,r,tmp=0,o,buy=0;
  12.     cout<<"「好事成雙」賽馬場"<<"第"<<t<<"局"<<endl;
  13.     cout<<"------------------------------------------------------------------------| 終點"<<endl;
  14.     cout<<"◆"<<endl;
  15.     cout<<"★"<<endl;
  16.     cout<<"▲"<<endl;
  17.     cout<<"●"<<endl<<endl;
  18.     cout<<"可用餘額:"<<z<<"元"<<endl<<endl;
  19.     cout<<"(1)買入 (2)下注 (3)離開 請選擇:";  
  20.     cin>>o;
  21.     if(o==1)
  22.     {
  23.         cout<<"買入:";
  24.         cin>>buy;
  25.         z += buy;
  26.         goto re;
  27.     }
  28.     system("pause");
  29.     system("cls");
  30.     string name[4] = {"◆","★","▲","●"};
  31.     srand(time(NULL));
  32.     string words ="賽馬進行中";
  33.     while(a<=70 && b<=70 && c<=70 && d<=70)
  34.     {
  35.         cout<<words<<endl;   
  36.         cout<<"------------------------------------------------------------------------| 終點"<<endl;  
  37.         r = rand()%4+1;
  38.         switch(r)
  39.         {
  40.             case 1:
  41.                  a++;
  42.                  break;
  43.             case 2:
  44.                  b++;
  45.                  break;
  46.             case 3:
  47.                  c++;
  48.                  break;
  49.             case 4:
  50.                  d++;      
  51.         }
  52.         for(int i=0;i<=a;i++)
  53.         {
  54.             cout<<" ";        
  55.         }
  56.         cout<<name[0]<<endl;  
  57.         for(int i=0;i<=b;i++)
  58.         {
  59.             cout<<" ";        
  60.         }
  61.         cout<<name[1]<<endl;  
  62.         for(int i=0;i<=c;i++)
  63.         {
  64.             cout<<" ";        
  65.         }
  66.         cout<<name[2]<<endl;  
  67.         for(int i=0;i<=d;i++)
  68.         {
  69.             cout<<" ";        
  70.         }
  71.         cout<<name[3]<<endl;
  72.         tmp = b==70 ? 1 :0;
  73.         tmp = c==70 ? 2 :0;
  74.         tmp = d==70 ? 3 :0;
  75.         if(a==70 || b==70 || c==70 || d==70)
  76.         {
  77.             if(a==70)
  78.                   tmp = 0;
  79.             if(b==70)
  80.                   tmp =1;
  81.             if(c==70)
  82.                   tmp =2;
  83.             if(d==70)
  84.                   tmp =3;
  85.             words = "比賽結束!由"+name[tmp]+"先馳得點!";;        
  86.         }
  87.         if(a==71 || b==71 || c==71 || d==71)
  88.         {
  89.         }else
  90.         {
  91.             system("cls");     
  92.         }     
  93.     }
  94.     system("pause");   
  95.     goto re;
  96.     return 0;   
  97. }
複製代碼

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. #include<ctime>
  4. using namespace std;
  5. int main()
  6. {
  7.     int t=0,z=0;
  8.     re:
  9.     system("cls");  
  10.     t++;
  11.     int a=0,b=0,c=0,d=0,r,tmp=0,o,buy=0;
  12.     cout<<"「好事成雙」賽馬場"<<"第"<<t<<"局"<<endl;
  13.     cout<<"------------------------------------------------------------------------| 終點"<<endl;
  14.     cout<<"◆"<<endl;
  15.     cout<<"★"<<endl;
  16.     cout<<"▲"<<endl;
  17.     cout<<"●"<<endl<<endl;
  18.     cout<<"可用餘額:"<<z<<"元"<<endl<<endl;
  19.     cout<<"(1)買入 (2)下注 (3)離開 請選擇:";  
  20.     cin>>o;
  21.     if(o==1)
  22.     {
  23.         cout<<"買入:";
  24.         cin>>buy;
  25.         z += buy;
  26.         goto re;
  27.     }
  28.     system("pause");
  29.     system("cls");
  30.     string name[4] = {"◆","★","▲","●"};
  31.     srand(time(NULL));
  32.     string words ="賽馬進行中";
  33.     while(a<=70 && b<=70 && c<=70 && d<=70)
  34.     {
  35.         cout<<words<<endl;   
  36.         cout<<"------------------------------------------------------------------------| 終點"<<endl;  
  37.         r = rand()%4+1;
  38.         switch(r)
  39.         {
  40.             case 1:
  41.                  a++;
  42.                  break;
  43.             case 2:
  44.                  b++;
  45.                  break;
  46.             case 3:
  47.                  c++;
  48.                  break;
  49.             case 4:
  50.                  d++;      
  51.         }
  52.         for(int i=0;i<=a;i++)
  53.         {
  54.             cout<<" ";        
  55.         }
  56.         cout<<name[0]<<endl;  
  57.         for(int i=0;i<=b;i++)
  58.         {
  59.             cout<<" ";        
  60.         }
  61.         cout<<name[1]<<endl;  
  62.         for(int i=0;i<=c;i++)
  63.         {
  64.             cout<<" ";        
  65.         }
  66.         cout<<name[2]<<endl;  
  67.         for(int i=0;i<=d;i++)
  68.         {
  69.             cout<<" ";        
  70.         }
  71.         cout<<name[3]<<endl;
  72.         tmp = b==70 ? 1 :0;
  73.         tmp = c==70 ? 2 :0;
  74.         tmp = d==70 ? 3 :0;
  75.         if(a==70 || b==70 || c==70 || d==70)
  76.         {
  77.             if(a==70)
  78.                   tmp = 0;
  79.             if(b==70)
  80.                   tmp =1;
  81.             if(c==70)
  82.                   tmp =2;
  83.             if(d==70)
  84.                   tmp =3;
  85.             words = "比賽結束!由"+name[tmp]+"先馳得點!";;        
  86.         }
  87.         if(a==71 || b==71 || c==71 || d==71)
  88.         {
  89.         }else
  90.         {
  91.             system("cls");     
  92.         }     
  93.     }
  94.     system("pause");   
  95.     goto re;
  96.     return 0;   
  97. }
複製代碼

TOP

返回列表