鱼丸07
2020-01-30 15:37
采纳率: 33.3%
浏览 501

C语言 发牌与洗牌的模拟

#include
#include
#include

void shuffle(int Deck[][13])
{
int i;
for(i=1;i<=52;i++)
{
int row = rand() % 4;
int column =rand() %13;
if(Deck[row][column]==0)
Deck[row][column]=i;
}

}

void deal(int Deck[][13],char *suit[],char *value[])
{
int i,column,row;
printf("玩家1\t玩家2\t玩家3\t玩家4\t");
for(i=1;i<=52;i++)
{
row=0;
if(row<=3)
{
column=0;
if(column<=12)
{
printf(" %c%2c",row,column);

        }
        if(i%4==0) printf("\n");
        column++;
    }
    row++;
}
return 0;

}
int main()
{
char *suit[4]={"红桃","方片","草花","黑桃"};
char *value[13]={"A","2","3","4","5","6","7","8","9","10","J","Q","K"};

int Deck[4][13];
srand(time(NULL));
shuffle(Deck);
deal(Deck,suit,value);
return 0;

}

图片说明

运行结果不对,哪位大神能看一看是哪里出错了吗?谢谢

1条回答 默认 最新

相关推荐 更多相似问题