标题:【求助】调试中断运行,输出显示不全,代码如下
只看楼主
Janssean
Rank: 1
等 级:新手上路
帖 子:14
专家分:0
注 册:2016-10-29
结帖率:66.67%
已结贴  问题点数:20 回复次数:3 
【求助】调试中断运行,输出显示不全,代码如下
程序代码:
#include<stdio.h>
#include<stdlib.h>
#include<time.h >
#include<conio.h>
struct card
{char *face;

 char *suit;
};
typedef struct card Card;
void fillDeck(Card *,char *[],char *[]);
void shuffle(Card *);
void deal(Card *);
int main()
{ Card deck[52];
  char *face[]={"1","2","3","4","5","6","7","8","9","10","11","12","13"};
  char *suit[]={"H","D","C","S"};
  srand (time(NULL));
  fillDeck(deck,face,suit);
  shuffle(deck);
  deal(deck);
  return 0;
}
void fillDeck(Card *wDeck,char *wFace[],char *wSuit[])
{ int i;
  for(i=0;i<51;i++)
  { wDeck[i].face=wFace[i%13];
    wDeck[i].suit=wSuit[i/13];
  }
}
void shuffle(Card *wDeck)
{ int i,j;
  Card temp;
  for(i=0;i<=51;i++)
  { j=rand()%52;
    temp=wDeck[i];
    wDeck[i]=wDeck[j];
    wDeck[j]=temp;
  }
}
void deal(Card *wdeck)
{ int i;
  for(i=0;i<=51;i++)
  printf("%2s--%2s%c",wdeck[i].suit,wdeck[i].face,(i+1)%4?'\t':'\n');
}


[此贴子已经被作者于2017-8-16 14:06编辑过]

搜索更多相关主题的帖子: include char face void int 
2017-08-16 13:35
Janssean
Rank: 1
等 级:新手上路
帖 子:14
专家分:0
注 册:2016-10-29
得分:0 
回复 楼主 Janssean
洗牌和发牌程序
2017-08-16 13:36
grmmylbs
Rank: 14Rank: 14Rank: 14Rank: 14
等 级:贵宾
威 望:54
帖 子:1409
专家分:5845
注 册:2016-2-14
得分:20 
程序代码:
void fillDeck(Card *wDeck, char *wFace[], char *wSuit[])
{
    int i;
    for (i = 0; i<=51; i++)
    {
        wDeck[i].face = wFace[i % 13];
        wDeck[i].suit = wSuit[i % 4];
    }
}
2017-08-16 13:48
Janssean
Rank: 1
等 级:新手上路
帖 子:14
专家分:0
注 册:2016-10-29
得分:0 
回复 3楼 grmmylbs
谢谢OK了

[此贴子已经被作者于2017-8-16 14:11编辑过]

2017-08-16 14:09



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-480086-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.016677 second(s), 7 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved