没有思路,求大佬提点,加急。
假设将红桃A到黑桃K这52张牌顺序排放并给他们每张牌对应编号如下0——>红桃A
1——>红桃2
......
12——>红桃K
13——>方片A
...
...
...
51——>黑桃K
先要求编程实现输入牌的编号,输出牌的花色和牌的牌面,
例如:输入
14
输出
方片 2(或者♦ 2)
提示:使用整除、取余的方法
#include <stdio.h> #include <string.h> int main(int argc, char** argv) { const char* type[] = {"红桃","方片","梅花","黑桃"}; const char* data[] = {"A","2","3","4","5","6","7","8","9","10","J","Q","K"}; int i = 0; while(1) { scanf("%d",&i); printf("%s%s\n",type[(i/13)%4],data[i%13]); } return 0; }
[此贴子已经被作者于2018-10-16 17:50编辑过]