✔ 最佳答案
以下是利用struct,把下面codes copy and paste入Notepad,另存xxx.c就可以Run!
#include < stdio.h >
#include < conio.h >
struct pokerCard //data structure of each poker card
{
char _number;
char _suit;
};
void main(void)
{
//given data suit and number
char suit[4] = {'S','H','C','D'};
char number[13] = {'A','2','3','4','5','6','7','8','9','T','J','Q','K'};
int i, j=0;
struct pokerCard p[4][13];//declaration of poker card array
//assignment
for (i=0;i<4;i++){
for (j=0;j<13;j++){
p[i][j]._suit = suit[i];
p[i][j]._number = number[j];
//printf("%c%c", p[i][j]._suit, p[i][j]._number);
}
}
//print out all
for (i=0;i<4;i++){
for (j=0;j<13;j++){
printf("Card [%d][%d]: %c%c \n", i+1,j+1,p[i][j]._suit, p[i][j]._number);
}
}
getchar();
}