返回列表 發帖
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     re:
  7.     srand(time(NULL));
  8.     string name[3]={"剪刀","石頭","布"};
  9.     int player,computer;
  10.     cout<<"請出拳:(1)剪刀(2)石頭(3)布"<<endl;
  11.     cin>>player;
  12.     computer=rand()%3+1;
  13.     if(player<1 || player>3)
  14.         {
  15.             cout<<"不要亂"<<endl;
  16.             goto re;        
  17.         }
  18.     cout<<"你出"<<name[player-1]<<endl;
  19.     cout<<"電腦出"<<name[computer-1]<<endl;   
  20.     system("pause");
  21.     return 0;   
  22. }
複製代碼

TOP

返回列表