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