#include <iostream>
#include <iomanip>
using namespace std;
void shuffle(int [][13]);//======洗牌======
void deal(const int [][13],const char *[],const char *[]);//=======一次发完牌======
int main()
{
const char *suit[4]={"红桃","黑桃","梅子","方块"};
const char *face[13]={"A","2","3","4","5",
"6","7","8","9","10",
"J","Q","K"};
int deck[4][13]={0};
shuffle(deck);
cout<<"/n=====================================================/n";
deal(deck,face,suit);
cout<<"/n=====================================================/n";
system("PAUSE");
return 0;
}
void shuffle(int wDeck[][13])
{
int row,col;
for(int card=1;card<=52;card++)
{
do
{
row=rand()%4;
col=rand()%13;
}while(wDeck[row][col]!=0);
wDeck[row][col]=card;
}
}
//======发牌========
void deal(const int wDeck[][13],const char *wFace[],const char *wSuit[])
{
for(int card=1;card<=52;card++)
for(int row=0;row<=3;row++)
for(int col=0;col<=12;col++)
{
if(wDeck[row][col]==card)
{
cout<<setw(4)<<setiosflags(ios::right)
<<wSuit[row]<<wFace[col]
<<(card%2==0?"/n":"/t");
}
}
cout<<"***************************************************/n";
}