- #include<iostream>
- #include<cstdlib>
- using namespace std;
- int main()
- {
- srand(time(NULL));
- int a,b;
- cout<<"請出拳 (1)剪刀 (2)石頭(3)布"<<endl;
- 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;
- }
複製代碼 |