| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 746 人关注过本帖
标题:扑克牌洗、发牌简化方法,求帮助,谢谢!
取消只看楼主 加入收藏
李西甲
Rank: 1
等 级:等待验证会员
帖 子:16
专家分:7
注 册:2011-12-5
结帖率:100%
收藏
已结贴  问题点数:15 回复次数:2 
扑克牌洗、发牌简化方法,求帮助,谢谢!
#include <stdlib.h>
#include <stdio.h>      
main()
{  
     int i,j,row,col;
     char* a[4][13]={{"He: A","He: 2","He:3","He: 4","He: 5","He: 6","He: 7","He: 8",
       "He: 9","He: 10","He: J","He: Q","He: K"},
     {"Di: A","Di: 2","Di:3","Di: 4","Di: 5","Di: 6","Di: 7","Di: 8","Di: 9","Di: 10",
       "Di: J","Di: Q","Di: K"},
     {"Cl: A","Cl: 2","Cl:3","Cl: 4","Cl: 5","Cl: 6","Cl: 7","Cl: 8","Cl: 9","Cl: 10",
       "Cl: J","Cl: Q","Cl: K"},
     {"Sp: A","Sp: 2","Sp:3","Sp: 4","Sp: 5","Sp: 6","Sp: 7","Sp: 8","Sp: 9","Sp: 10",
       "Sp: J","Sp: Q","Sp: K"}};     
     char* deck[4][13];
     srand(time(NULL));
     for(i=0;i<4;i++)      //洗牌
     {  
        for(j=0;j<13;j++)
        {
            row=rand()%4;
            col=rand()%13;
            deck[i][j]=a[row][col];
        }
     }
     for(i=0;i<4;i++)      //发牌
     {
         for(j=0;j<13;j++)
            printf("%8s",deck[i][j]);
         printf("\n");
     }
     getchar();
     getchar();
}
//////char* a[4][13]的初始化如何变得简洁,求帮助,知道的讲一下,谢谢!
搜索更多相关主题的帖子: 扑克牌 include 
2011-12-07 23:12
李西甲
Rank: 1
等 级:等待验证会员
帖 子:16
专家分:7
注 册:2011-12-5
收藏
得分:0 
恩,    我改成这样:#include <stdlib.h>
 #include <stdio.h>      
 main()
 {  
      int i,j,row,col;
      char* a[4][13]={{"He: A","He: 2","He:3","He: 4","He: 5","He: 6","He: 7","He: 8",
        "He: 9","He: 10","He: J","He: Q","He: K"},
      {"Di: A","Di: 2","Di:3","Di: 4","Di: 5","Di: 6","Di: 7","Di: 8","Di: 9","Di: 10",
        "Di: J","Di: Q","Di: K"},
      {"Cl: A","Cl: 2","Cl:3","Cl: 4","Cl: 5","Cl: 6","Cl: 7","Cl: 8","Cl: 9","Cl: 10",
        "Cl: J","Cl: Q","Cl: K"},
      {"Sp: A","Sp: 2","Sp:3","Sp: 4","Sp: 5","Sp: 6","Sp: 7","Sp: 8","Sp: 9","Sp: 10",
        "Sp: J","Sp: Q","Sp: K"}};     
      char* deck[4][13];
     char* p;
      srand(time(NULL));
      for(i=0;i<4;i++)      //洗牌
      {  
         for(j=0;j<13;j++)
         {
            p=a[i][j];
             row=rand()%4;
             col=rand()%13;
             deck[i][j]=a[row][col];
            a[row][col]=p;
         }
      }
      for(i=0;i<4;i++)      //发牌
     {
          for(j=0;j<13;j++)
             printf("%8s",deck[i][j]);
          printf("\n");
      }
      getchar();
      getchar();
}
可以吗?
2011-12-09 00:03
李西甲
Rank: 1
等 级:等待验证会员
帖 子:16
专家分:7
注 册:2011-12-5
收藏
得分:0 
回复 7楼 zy_space
谢谢
2011-12-09 12:36
快速回复:扑克牌洗、发牌简化方法,求帮助,谢谢!
数据加载中...
 
   



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

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