- #include<iostream>
- #include<cstdlib>
- #include<ctime>
- using namespace std;
- int main()
- {
- srand(time(NULL));
- int player, computer;
- re:
- string n[]={"剪刀","石頭","布"};
- cout<<"請出拳! <1>剪刀 <2>石頭 <3>布";
- cin>>player;
- computer=rand()%3+1
- cout<<"你出"<<n[player-1]<<"!"<<endl;
- cout<<"電腦出"<<n[computer-1]<<"!"<<endl;
- goto re;
- system("pause");
- return 0;
- }
複製代碼 |