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

TOP

返回列表