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