返回列表 發帖
  1. #include<iostream>
  2. #include<cstdlib>
  3. #include<time.h>
  4. using namespace std;
  5. int main()
  6. {
  7.   re:
  8.   system("cls");        
  9.   srand(time(NULL));
  10.   int player=0;
  11.   int com=0;
  12.   string mora[]={"剪刀","石頭","布"};
  13.   cout<< "請輸入你想要出的拳   (1)剪刀(2)石頭(3)布" <<endl;
  14.   cin>>player;
  15.   cout<< "電腦出拳中..." <<endl;
  16.   com=(rand()%3)+1;
  17.   cout<< "電腦出" << mora[com-1] <<endl;
  18.   if(player==1&&com==3)
  19.   cout<<"你贏了"<<endl;
  20.   else if(player==2&&com==1)
  21.   cout<<"你贏了"<<endl;
  22.   else if(player==3&&com==2)
  23.   cout<<"你贏了"<<endl;
  24.   else if(player==com)
  25.   cout<<"平手"<<endl;
  26.   else
  27.   cout<<"你輸了"<<endl;   
  28. system("pause");
  29. goto re;
  30. return 0;
  31. }
複製代碼

TOP

返回列表