返回列表 發帖

RE: 賽馬程式ewhfrtguo4;35

  1. #include<iostream>
  2. #include<cstdlib>
  3. #include<ctime>
  4. using namespace std;
  5. int main()
  6. {
  7.     cout<<"「好事成雙」賽馬場"<<endl;
  8.     cout<<"------------------------------------------------------------------------| 終點"<<endl;
  9.     cout<<"◆"<<endl;
  10.     cout<<"★"<<endl;
  11.     cout<<"▲"<<endl;
  12.     cout<<"●"<<endl;
  13.     system("pause");
  14.     system("cls");
  15.     srand(time(NULL));

  16.     int a=0,b=0,c=0,d=0,r;
  17.     string words ="賽馬進行中";
  18.     while(a<=70 && b<=70 && c<=70 && d<=70)
  19.     {  
  20.       cout<<words<<endl;
  21.       cout<<"------------------------------------------------------------------------| 終點"<<endl;   
  22.       r = rand()%4+1;
  23.       
  24.       switch(r)
  25.       {
  26.           case 1:
  27.                a++;
  28.                break;
  29.           case 2:
  30.                b++;
  31.                break;
  32.           case 3:
  33.                c++;
  34.                break;
  35.           case 4:
  36.                d++;
  37.                break;
  38.       }
  39.       

  40.       for(int i=0;i<=a;i++)
  41.       {
  42.           cout<<" ";
  43.       }
  44.       cout<<"◆"<<endl;
  45.       
  46.       for(int i=0;i<=b;i++)
  47.       {
  48.           cout<<" ";
  49.       }
  50.       cout<<"★"<<endl;
  51.       
  52.       for(int i=0;i<=c;i++)
  53.       {
  54.           cout<<" ";
  55.       }
  56.       cout<<"▲"<<endl;
  57.       
  58.       for(int i=0;i<=d;i++)
  59.       {
  60.           cout<<" ";
  61.       }
  62.       cout<<"●"<<endl;
  63.       
  64.       if(a==70 || b==70 || c==70 || d==70)
  65.       {
  66.          words = "賽馬完成";
  67.       }

  68.       if(a==71 || b==71 || c==71 || d==71)
  69.       {      
  70.       }else{      
  71.         system("cls");
  72.       }
  73.       
  74.     }
  75.       
  76.     system("pause");
  77.     return 0;   
  78. }
複製代碼

TOP

返回列表