- #include<iostream>
- #include<cstdlib>
- using namespace std;
- int main()
- {
- int a, b ,c ,d ,bigger;
- srand(time(NULL));
- re:
- a=rand()%4+3;
- b=rand()%13+1;
- c=rand()%4+3;
- d=rand()%13+1;
- cout<<"你抽到的牌是: "<<char(a);
- if(b==1)
- cout<<"A"<<endl;
- if(b>1 && b<11)
- cout<<b<<endl;
- if(b==11)
- cout<<"J"<<endl;
- if(b==12)
- cout<<"Q"<<endl;
- if(b==13)
- cout<<"K"<<endl;
- cout<<"電腦抽到的牌是: "<<char(c);
- if(d==1)
- cout<<"A"<<endl;
- if(d>1 && d<11)
- cout<<d<<endl;
- if(d==11)
- cout<<"J"<<endl;
- if(d==12)
- cout<<"Q"<<endl;
- if(d==13)
- cout<<"K"<<endl;
-
- if(b>d)
- cout<<"你贏了!"<<endl;
- else if(d>b)
- cout<<"你輸了!"<<endl;
- else
- cout<<"平手!"<<endl;
- system("pause");
- goto re;
- system("pause");
- return 0;
- }
複製代碼 |