写在前面
- 思路分析
- 简单模拟
-
starts
和ends
数组保存每1次变换的开始顺序和结束顺序(以1~54的编号存储) - 根据编号与扑克牌字母数字对应关系输出
ends
数组
- 问题点
- 下标进制转换,
13
- 细节处理
- 细节处理耗费时间,25分钟a题
测试用例
input:
2
36 52 37 38 3 39 40 53 54 41 11 12 13 42 43 44 2 4 23 24 25 26 27 6 7 8 48 49 50 51 9 10 14 15 16 5 17 18 19 1 20 21 22 28 29 30 31 32 33 34 35 45 46 47
output:
ac代码
- 参考链接
#include <cstdio>
using namespace std;
int main()
{
int cnt;
scanf("%d", &cnt);
int starts[55], ends[55], scan[55];
// 存储输入
for(int i=1; i<55; i++)
{
scanf("%d", &scan[i]);
ends[i] = i;
}
for(int i=0; i<cnt; i++)
{
for(int j=1; j<55; j++)
starts[j] = ends[j];
for(int k=1; k<55; k++)
ends[scan[k]] = starts[k];
}
char c[6] = {"SHCDJ"};
for(int i=1; i<55; i++)
{
// 字母切换, 进制转换 [细节处理]
printf("%c%d", c[(ends[i]-1)/13], (ends[i]-1)%13+1);
if(i != 54) printf(" ");
}
return 0;
}