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