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

TOP

返回列表