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