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