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