用结构体编的模拟发扑克牌的过程
#include<stdio.h>#include<string.h>
#include<stdlib.h>
#include<time.h>
struct card
{
char huase[10];
char daxiao[10];
};
main()
{
time_t ti;
char *huase[]={{"heitao"},{"hontao"},{"fangkuai"},{"mianhua"}};
char daxiao[]={'A','2','3','4','5','6','7','8','10','J','Q','K'};
int i,j;
int result[52]={0};
struct card Card[52];
for(i=0;i<52;i++)
result[i]=70;
for(i=0;i<52;i++)
{
strcpy(Card[i].huase,huase[i\13]);
strcpy(Card[i].daxiao,daxiao[i%13]);
}
srand(time(NULL));
i=0;
while(1)
{
result[i]=rand()%52;
for(j=0;j<i;j++)
{
if(result[j]==result[i])
break;
}
if(j<i)
continue;
i++;
if(i>=52)
break;
}
for(i=0;i<52;i++)
{
printf("%10s %5s\n",Card[result[i]].huase,Card[result[i]].daxiao);
}
}
不知道这个程序那里有问题?帮忙指点一下!谢了!