写了一个c语言程序编译通过了但运行不出结果
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#define N 52
#define NumofPlayer 3
typedef struct card
{
char suit[10];
char face[10];
}CARD;
void New(CARD newCard[N],char suit[4][10],char face[13][10]);
void Shuffle(CARD newCard[N],CARD a[N],char suit[][10],char face[][10]);
void Deal(CARD a[N],int n);
int main()
{
CARD card[N];
char suit[4][10] = {"Spades","Hearts","Clubs","Diamonds"};
char face[13][10] = {"A","2","3","4","5","6","7","8",
"9","10","Jack","Queen","King"};
CARD newCard[N];
New(newCard,suit,face);
Shuffle(newCard,card,suit,face);
Deal(card,NumofPlayer);
return 0;
}
void New(CARD newCard[N],char suit[4][10],char face[13][10])
{
int i,j;
int k = 0;
for(i = 0;i < 4;i++)
{
for(j = 0;j < 13;j++)
{
strcpy(newCard[k].suit , suit[i]);
strcpy(newCard[k].face , face[j]);
k++;
}
}
}
void Shuffle(CARD newCard[N],CARD a[N],char suit[][10],char face[][10])
{
int i,j;
int flag;
int k[52];
for(i = 0;i < N;i++)
{
flag = 1;
srand(time(NULL));
k[i] = rand() %52;
for(j = 0;j <= i;j++)
{
if(k[i] == k[j])
flag = 0;
i--;
}
if(flag)
{
a[i] = newCard[k[i]];
}
}
}
void Deal(CARD a[N],int n)
{
int i,j;
int k = 0;
for(i = 0;i < n;i++)
{
printf("Player %d:",i + 1);
for(j = 0;j < N/n;j++)
{
printf(" %s\t%s |",a[k].suit,a[k].face);
k++;
}
printf("\n");
}
}
编译通过了,但运行时没有任何输出
编程模拟洗牌和发牌,其中有4种花色13种牌面共52张牌,每张牌包括两个字符型数组类型的数据成员