返回列表 發帖
本帖最後由 陳宇柏 於 2019-11-12 17:34 編輯
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     srand(time(NULL));
  7.    int computer,player;
  8.    cout<<"請出拳(1)剪刀 (2)石頭 (3)布";
  9.    cin>>player;
  10.    computer=rand()%3+1;
  11.    cout<<"你出的是";
  12.    if(player==1)
  13.    {
  14.     cout<<"剪刀"<<endl;            
  15.    }
  16.     if(player==2)
  17.    {
  18.     cout<<"石頭"<<endl;            
  19.    }
  20.    
  21.     if(player==3)
  22.    {
  23.     cout<<"布"<<endl;            
  24.    }
  25.    
  26.    
  27.    cout<<"電腦出的是";
  28.    if(computer==1)
  29.    {
  30.     cout<<"剪刀"<<endl;            
  31.    }
  32.     if(computer==2)
  33.    {
  34.     cout<<"石頭"<<endl;            
  35.    }
  36.    
  37.     if(computer==3)
  38.    {
  39.     cout<<"布"<<endl;            
  40.    }
  41.     system ("pause");   
  42.     return 0;
  43. }   

  44.    
複製代碼

TOP

返回列表