返回列表 發帖
本帖最後由 章幼莛 於 2019-4-20 14:42 編輯
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     re:
  7.     int a=0,b=0,c=0,d=0,h;
  8.     cout<<"「好事成雙」賽馬場"<<endl;
  9.     cout<<"|--------------------------------------------------|"<<endl;
  10.     cout<<"◆"<<endl;
  11.     cout<<"★"<<endl;
  12.     cout<<"▲"<<endl;
  13.     cout<<"●"<<endl;
  14.     system("pause");
  15.     system("cls");
  16.     srand(time(NULL));
  17.    
  18.     while(a!=50 && b!=50 && c!=50 && d!=50)
  19.     {
  20.           cout<<"賽馬進行中"<<endl;
  21.           cout<<"|--------------------------------------------------|"<<endl;
  22.           h = rand()%4+1;
  23.           if(h==1)
  24.              a++;
  25.           if(h==2)
  26.              b++;
  27.           if(h==3)
  28.              c++;
  29.           if(h==4)
  30.              d++;
  31.             
  32.           for(int i=0;i<=a;i++)
  33.           {
  34.                   cout<<" ";
  35.           }
  36.           cout<<"◆"<<endl;
  37.           for(int i=0;i<=b;i++)
  38.           {
  39.                   cout<<" ";
  40.           }
  41.           cout<<"★"<<endl;
  42.           for(int i=0;i<=c;i++)
  43.           {
  44.                   cout<<" ";
  45.           }
  46.           cout<<"▲"<<endl;
  47.           for(int i=0;i<=d;i++)
  48.           {
  49.                   cout<<" ";
  50.           }
  51.           cout<<"●"<<endl;
  52.           system("cls");
  53.     }
  54.     cout<<"比賽結束"<<endl;
  55.     cout<<"|--------------------------------------------------|"<<endl;
  56.     for(int i=0;i<=a;i++)
  57.     {
  58.         cout<<" ";
  59.     }
  60.     cout<<"◆"<<endl;
  61.     for(int i=0;i<=b;i++)
  62.     {
  63.         cout<<" ";
  64.     }
  65.     cout<<"★"<<endl;
  66.     for(int i=0;i<=c;i++)
  67.     {
  68.         cout<<" ";
  69.     }
  70.     cout<<"▲"<<endl;
  71.     for(int i=0;i<=d;i++)
  72.     {     
  73.         cout<<" ";
  74.     }
  75.     cout<<"●"<<endl;
  76.     system("pause");
  77.     system("cls");
  78.     goto re;
  79.    
  80.     system("pause");
  81.     return 0;
  82. }
複製代碼

TOP

返回列表