返回列表 發帖
  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.     int a=0,b=0,c=0,d=0,r,opition,buyin;
  10.    re:
  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>>opition;
  22.     if(option==1)
  23.     {
  24.         cout<<"買入:";
  25.         cin>>buyin;
  26.         blance += buyin;
  27.         goto re;
  28.     }
  29.    system("pause");
  30.    system("cls");  
  31.    srand(time(NULL));
  32.    
  33.    
  34.    int a=0,b=0,c=0,d=0,r,opition,buyin;
  35.    string words ="賽馬進行中";
  36.    string name[4]={"Ⅰ","Ⅱ","Ⅲ","Ⅳ"};
  37.    while(a<=70 && b<=70 && c<=70 && d<=70)
  38.    {
  39.                 cout<<words<<endl;
  40.       cout<<"------------------------------------------------------------------------| 終點"<<endl;   
  41.      r=rand()%4+1;
  42.      switch(r)
  43.      {     
  44.            case 1:      
  45.               a++;           
  46.               break;
  47.            case 2:      
  48.               b++;           
  49.               break;
  50.            case 3:      
  51.               c++;           
  52.               break;      
  53.            case 4:      
  54.               d++;           
  55.               break;   
  56.      }
  57.       for(int i=0;i<=a;i++)
  58.       {
  59.           cout<<" ";
  60.       }
  61.        cout<<name[0]<<endl;
  62.      
  63.        for(int i=0;i<=b;i++)
  64.       {
  65.           cout<<" ";
  66.       }
  67.        cout<<name[1]<<endl;
  68.       
  69.        for(int i=0;i<=c;i++)
  70.       {
  71.           cout<<" ";
  72.       }
  73.        cout<<name[2]<<endl;
  74.       
  75.        for(int i=0;i<=d;i++)
  76.       {
  77.           cout<<" ";
  78.       }
  79.        cout<<name[3]<<endl;
  80.       
  81.        if(a==70 || b==70 || c==70 || d==70)
  82.        {
  83.            int position;     
  84.            if(a==70)
  85.               position = 0;
  86.          if(b==70)
  87.               position =1;
  88.          if(c==70)
  89.               position =2;
  90.          if(d==70)
  91.               position =3;           
  92.            words = "比賽結束,由"+name[position]+"奪魁";     
  93.        }
  94.        if(a==71 || b==71 || c==71 || d==71)
  95.        {
  96.        }else{
  97.              system("cls");         
  98.        }   
  99.                      
  100.    }
  101.   n++;
  102. system("pause");
  103. system("cls");
  104. goto re;   
  105. return 0;   
  106. }
複製代碼

TOP

返回列表