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