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