本帖最後由 陳宇柏 於 2019-11-12 17:34 編輯
- #include<iostream>
- #include<cstdlib>
- using namespace std;
- int main()
- {
- srand(time(NULL));
- int computer,player;
- cout<<"請出拳(1)剪刀 (2)石頭 (3)布";
- cin>>player;
- computer=rand()%3+1;
- cout<<"你出的是";
- if(player==1)
- {
- cout<<"剪刀"<<endl;
- }
- if(player==2)
- {
- cout<<"石頭"<<endl;
- }
-
- if(player==3)
- {
- cout<<"布"<<endl;
- }
-
-
- cout<<"電腦出的是";
- if(computer==1)
- {
- cout<<"剪刀"<<endl;
- }
- if(computer==2)
- {
- cout<<"石頭"<<endl;
- }
-
- if(computer==3)
- {
- cout<<"布"<<endl;
- }
- system ("pause");
- return 0;
- }
-
複製代碼 |