| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 823 人关注过本帖
标题:高手帮忙看下 怎么输不出结果....
只看楼主 加入收藏
apologize
Rank: 1
等 级:新手上路
帖 子:14
专家分:7
注 册:2011-10-12
结帖率:100%
收藏
已结贴  问题点数:10 回复次数:5 
高手帮忙看下 怎么输不出结果....
#include "stdio.h"
#include "stdlib.h"
#include "time.h"
int shuffle(int wdeck[4][13]);/*洗牌*/
int deal(int wdeck[][13],char *wface[4],char *wsuit[13]);/*发牌*/
int main(void)
{char *wface[4]={"heart","diamond","club","spade"};
char *wsuit[13]={"Ace","Deuc","Three","Four","Five","Six","Seven","Eight","Nine","Ten","Jack","Queen","King"};
int wdeck[4][13]={"0"};
srand(time(NULL));
shuffle(wdeck);
deal(wdeck,wface,wsuit);
return 0;}


 int shuffle(int wdeck[4][13])
 {int card,row,column;
 int r;
      for(card=1;card<=52;card++)
      {   r=rand();
          row=r%4;
          r=rand();
          column=r%13;
          while (wdeck[row][column]!=0)
          {   r=rand();
          row=r%4;
          r=rand();
          column=r%13;
          }
      wdeck[row][column]=card;
      }
 }
  int deal(int wdeck[][13],char *wface[4],char *wsuit[13])
  {
      int card,row,column;
      for(card=1;card<=52;card++){
          for(row=0;row<4;row++){
              for(column=0;column<=12;column++)
                  printf("%cof%-5s%c",wsuit[row],wface[column],card%4==0?'\n':'\t');}
      }
  }
搜索更多相关主题的帖子: shuffle diamond include return heart 
2011-10-27 18:46
a76503279
Rank: 2
等 级:论坛游民
帖 子:21
专家分:13
注 册:2011-9-30
收藏
得分:0 
肚子痛。  先上WC先。。呆会看,,唉呀。。闪。
2011-10-27 18:51
apologize
Rank: 1
等 级:新手上路
帖 子:14
专家分:7
注 册:2011-10-12
收藏
得分:0 
没人给答案......
2011-10-27 19:26
wuyijiang07
Rank: 3Rank: 3
等 级:论坛游侠
帖 子:74
专家分:177
注 册:2011-10-21
收藏
得分:10 
程序代码:
for(card=1;card<=52;card++){
          for(row=0;row<4;row++){
              for(column=0;column<=12;column++)
                  printf("%cof%-5s%c",wsuit[row],wface[column],card%4==0?'\n':'\t');}
      }
wface和wsuit搞反了,还有感觉这两个应该都用%s输出
还有int wdeck[4][13]={"0"};有问题,0不用加引号吧
 
2011-10-27 20:07
apologize
Rank: 1
等 级:新手上路
帖 子:14
专家分:7
注 册:2011-10-12
收藏
得分:0 
高手 谢谢指教,问题解决了,不过运行结果不是我想要的,自己在调试一下吧
2011-10-27 20:32
apologize
Rank: 1
等 级:新手上路
帖 子:14
专家分:7
注 册:2011-10-12
收藏
得分:0 
#include "stdio.h"
#include "stdlib.h"
#include "time.h"
int shuffle(int wdeck[4][13]);
int deal(int wdeck[][13],char *wface[4],char *wsuit[13]);
int main(void)
{char *wface[4]={"heart","diamond","club","spade"};
char *wsuit[13]={"Ace","Deuc","Three","Four","Five","Six","Seven","Eight","Nine","Ten","Jack","Queen","King"};
int wdeck[4][13]={0};
srand(time(NULL));
shuffle(wdeck);
deal(wdeck,wface,wsuit);
return 0;}


 int shuffle(int wdeck[4][13])
 {int card,row,column;
 int r;
      for(card=1;card<=52;card++)
      {   r=rand();
          row=r%4;
          r=rand();
          column=r%13;
          while (wdeck[row][column]!=0)
          {   r=rand();
          row=r%4;
          r=rand();
          column=r%13;
          }
      wdeck[row][column]=card;
      printf("%d,%d\t",row,column);
      }printf("\n");
 }
 
 int deal(int wdeck[][13],char *wface[4],char *wsuit[13])
  {
      int card,row,column;
      for(card=1;card<=52;card++){
          for(row=0;row<4;row++){
              for(column=0;column<=12;column++){
                  if(wdeck[row][column]==card)
                      printf("%sof%-5s%c",wface[row],wsuit[column],card%4==0?'\n':'\t');
          }}
      }
  }
哈哈 终于得到想要的结果了  结果中的数字是测试用的
2011-10-27 20:52
快速回复:高手帮忙看下 怎么输不出结果....
数据加载中...
 
   



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

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