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