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