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