求路过的大佬解决 发牌问题
题目编制一个模拟发牌的程序。有编号为1,2,3,4四个人,将一付去掉大小怪的扑克按照如下顺序排列梅花c0-c12,方块d0-d12,红桃h0--h12,黑桃s0-s12,然后按照1,2,3,4四个人的顺序发牌,问最后每个人手上的牌有哪些。
程序代码:
#include<stdio.h> int main() { char type[5] = {'c','d','h','s','\0'}; int card[13] = {0,1,2,3,4,5,6,7,8,9,10,11,12}; char people[4][26]; int n, i, j, p, q; for(i = 0; i < 4; i++) { for(j = 0; j < 13; j++) { people[p][q++] = type[i]; people[p][q++] = card[j]; p++; if(p == 4) p = 0; } } while(scanf("%d",&n) == 1) { for(i = 0; i < 26; i++) { while(i != 0) printf(" "); printf("%c",people[n][i]); } printf("\n"); } return 0; }
最终不行 求大佬解决