扑克牌洗、发牌简化方法,求帮助,谢谢!
#include <stdlib.h>#include <stdio.h>
main()
{
int i,j,row,col;
char* a[4][13]={{"He: A","He: 2","He:3","He: 4","He: 5","He: 6","He: 7","He: 8",
"He: 9","He: 10","He: J","He: Q","He: K"},
{"Di: A","Di: 2","Di:3","Di: 4","Di: 5","Di: 6","Di: 7","Di: 8","Di: 9","Di: 10",
"Di: J","Di: Q","Di: K"},
{"Cl: A","Cl: 2","Cl:3","Cl: 4","Cl: 5","Cl: 6","Cl: 7","Cl: 8","Cl: 9","Cl: 10",
"Cl: J","Cl: Q","Cl: K"},
{"Sp: A","Sp: 2","Sp:3","Sp: 4","Sp: 5","Sp: 6","Sp: 7","Sp: 8","Sp: 9","Sp: 10",
"Sp: J","Sp: Q","Sp: K"}};
char* deck[4][13];
srand(time(NULL));
for(i=0;i<4;i++) //洗牌
{
for(j=0;j<13;j++)
{
row=rand()%4;
col=rand()%13;
deck[i][j]=a[row][col];
}
}
for(i=0;i<4;i++) //发牌
{
for(j=0;j<13;j++)
printf("%8s",deck[i][j]);
printf("\n");
}
getchar();
getchar();
}
//////char* a[4][13]的初始化如何变得简洁,求帮助,知道的讲一下,谢谢!