返回列表 發帖
  1. #include<iostream>
  2. #include<cstdlib>
  3. #include<ctime>
  4. using namespace std;
  5. int main()
  6. {
  7.     srand(time(NULL));
  8.     int a,b;
  9.     cout<<"請出拳 1剪刀2石頭3布";
  10.     cin>>a;
  11.     b=rand()%3+1;
  12.     cout<<"你出了:";
  13.     if(a==1)
  14.     {
  15.       cout<<"剪刀"<<endl;   
  16.     }
  17.     if(a==2)
  18.     {
  19.       cout<<"石頭"<<endl;   
  20.     }
  21.     if(a==3)
  22.     {
  23.       cout<<"布"<<endl;   
  24.     }
  25.     cout<<"電腦出了:";
  26.     if(b==1)
  27.     {
  28.       cout<<"剪刀"<<endl;   
  29.     }
  30.     if(b==2)
  31.     {
  32.       cout<<"石頭"<<endl;   
  33.     }
  34.     if(b==3)
  35.     {
  36.       cout<<"布"<<endl;   
  37.     }
  38.     system("pause");
  39.     return 0;
  40. }
複製代碼

TOP

返回列表