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

TOP

返回列表