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