返回列表 發帖
  1. #include<iostream>
  2. #include<cstdlib>
  3. #include<ctime>
  4. using namespace std;
  5. int main()
  6. {
  7.         int p,c;
  8.     srand(time(NULL));
  9.     cout<<"請出拳(1)剪刀(2)石頭(3)布:";
  10.     cin>>p;
  11.     cout<<"玩家出:";
  12.     if(p==1)
  13.     cout<<"剪刀"<<endl;
  14.     if(p==2)
  15.     cout<<"石頭"<<endl;
  16.     if(p==3)
  17.     cout<<"布"<<endl;
  18.     c=rand()%3+1;
  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

返回列表