#include <stdlib.h>
#include <stdio.h>
int pk[]={501,502,
101,102,103,104,105,106,107,108,109,110,111,112,113,
201,202,203,204,205,206,207,208,209,210,211,212,213,
301,302,303,304,305,306,307,308,309,310,311,312,313,
401,402,403,404,405,406,407,408,409,410,411,412,413};
int a[14],b[14],c[13],d[13];
class pack
{
public:
void makepack();
void fapack();
void disp();
};
void pack::makepack()
{
int temp,r,times;
cout<<"\n 洗牌次数:";
cin>>times;
cout<<endl;
for(int j=0;j<=times;j++)
{
for(int i=0;i<53;i++)
{
r=int(float(53-i)*rand()/RAND_MAX)+1;
temp=pk[i];
pk[i]=pk[r];
pk[r]=temp;
}
}
}
void pack::fapack()
{
int i,j;
j=0;
cout<<"正在发牌..."<<endl;
for(i=0;i<=53;i++)
{
a[j]=pk[i];
i++;
b[j]=pk[i];
i++;
if(j<=12)
{
c[j]=pk[i];
i++;
d[j]=pk[i];
}
if(j>12)
i++;
j++;
}
}
void pack::disp()
{
cout<<"a的牌是:";
for(int i=0;i<14;i++)
cout<<a[i]<<",";
cout<<endl;
cout<<"b的牌是:";
for(i=0;i<14;i++)
cout<<b[i]<<",";
cout<<endl;
cout<<"c的牌是:";
for(i=0;i<13;i++)
cout<<c[i]<<",";
cout<<endl;
cout<<"d的牌是:";
for(i=0;i<13;i++)
cout<<d[i]<<",";
cout<<endl;
}
int main()
{
cout<<"==============模拟洗牌&&发牌==============="<<endl;
cout<<"=说明: ="<<endl;
cout<<"= 以5开头的为鬼 ="<<endl;
cout<<"= 以1开头的为红桃 ="<<endl;
cout<<"= 以2开头的为方块 ="<<endl;
cout<<"= 以3开头的为葵扇 ="<<endl;
cout<<"= 以4开头的为草花 ="<<endl;
cout<<"==========================================="<<endl;
pack mypack;
mypack.makepack();
mypack.fapack();
cout<<endl;
mypack.disp();
getchar();
return 0;
}