好友
阅读权限10
听众
最后登录1970-1-1
|
没找出错误呀,为什么编译出的牌还奇怪呀,求解。。。。。
#include<stdio.h>
#include<time.h>
#include<stdlib.h>
#define NUM_S 4
#define NUM_R 13
#define TRUE 1
#define FALSE 0
main()
{
int in_hand[NUM_S][NUM_R]={0};
int num_cards,rank,suit,i;
const char rank_num[]={'2','3','4','5','6','7','8',
'9','t','j','q','k','a'};
char suit_num[4][8]={"hong","lan","lv","huang"};
srand((unsigned)time(NULL));
printf("请输入手牌的数量\n");
scanf("%d",&num_cards);
while(num_cards>0)
{rank=rand() % NUM_R;
suit=rand() % NUM_S;
if (!in_hand[suit][rank])
{
in_hand[suit][rank]=TRUE;
num_cards--;
for(i=0;i<=8;i++)
printf("%c",suit_num[suit][i]);
printf("%c\n",rank_num[rank]);
}
}
printf("\n");
return 0;
}
|
|
发帖前要善用【论坛搜索】功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。 |
|
|
|
|