题目描述
液晶屏上,每个阿拉伯数字都是可以显示成 3×5 的点阵的(其中 X 表示亮点,. 表示暗点)。现在给出数字位数(不超过 100)和一串数字,要求输出这些数字在显示屏上的效果。数字的显示方式如同样例输出,注意每个数字之间都有一列间隔。
输入格式
无
输出格式
无
输入输出样例
输入
1 2 3 | 1 10 0123456789 |
输出
1 2 3 4 5 | XXX...X.XXX.XXX.X.X.XXX.XXX.XXX.XXX.XXX X.X...X...X...X.X.X.X...X.....X.X.X.X.X X.X...X.XXX.XXX.XXX.XXX.XXX...X.XXX.XXX X.X...X.X.....X...X...X.X.X...X.X.X...X XXX...X.XXX.XXX...X.XXX.XXX...X.XXX.XXX |
思路
暴力输出,就是太麻烦,还有sscanf的格式要注意
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 | #include<iostream> #include<cstdio> using namespace std; char ss[10][5][4]; int main() { int n, i, j, num; char s[105]; scanf("%d",&n); scanf("%s",s); sscanf("XXX\0","%s",ss[0][0]); sscanf("X.X\0","%s",ss[0][1]); sscanf("X.X\0","%s",ss[0][2]); sscanf("X.X\0","%s",ss[0][3]); sscanf("XXX\0","%s",ss[0][4]); sscanf("..X\0","%s",ss[1][0]); sscanf("..X\0","%s",ss[1][1]); sscanf("..X\0","%s",ss[1][2]); sscanf("..X\0","%s",ss[1][3]); sscanf("..X\0","%s",ss[1][4]); sscanf("XXX\0","%s",ss[2][0]); sscanf("..X\0","%s",ss[2][1]); sscanf("XXX\0","%s",ss[2][2]); sscanf("X..\0","%s",ss[2][3]); sscanf("XXX\0","%s",ss[2][4]); sscanf("XXX\0","%s",ss[3][0]); sscanf("..X\0","%s",ss[3][1]); sscanf("XXX\0","%s",ss[3][2]); sscanf("..X\0","%s",ss[3][3]); sscanf("XXX\0","%s",ss[3][4]); sscanf("X.X\0","%s",ss[4][0]); sscanf("X.X\0","%s",ss[4][1]); sscanf("XXX\0","%s",ss[4][2]); sscanf("..X\0","%s",ss[4][3]); sscanf("..X\0","%s",ss[4][4]); sscanf("XXX\0","%s",ss[5][0]); sscanf("X..\0","%s",ss[5][1]); sscanf("XXX\0","%s",ss[5][2]); sscanf("..X\0","%s",ss[5][3]); sscanf("XXX\0","%s",ss[5][4]); sscanf("XXX\0","%s",ss[6][0]); sscanf("X..\0","%s",ss[6][1]); sscanf("XXX\0","%s",ss[6][2]); sscanf("X.X\0","%s",ss[6][3]); sscanf("XXX\0","%s",ss[6][4]); sscanf("XXX\0","%s",ss[7][0]); sscanf("..X\0","%s",ss[7][1]); sscanf("..X\0","%s",ss[7][2]); sscanf("..X\0","%s",ss[7][3]); sscanf("..X\0","%s",ss[7][4]); sscanf("XXX\0","%s",ss[8][0]); sscanf("X.X\0","%s",ss[8][1]); sscanf("XXX\0","%s",ss[8][2]); sscanf("X.X\0","%s",ss[8][3]); sscanf("XXX\0","%s",ss[8][4]); sscanf("XXX\0","%s",ss[9][0]); sscanf("X.X\0","%s",ss[9][1]); sscanf("XXX\0","%s",ss[9][2]); sscanf("..X\0","%s",ss[9][3]); sscanf("XXX\0","%s",ss[9][4]); for (i = 0; i < 5; ++i) { int flag = 0; for (j = 0; j < n; ++j) { num = s[j] - '0'; if (flag) { printf(".%s",ss[num][i]); } else if(!flag) { printf("%s",ss[num][i]); } flag = 1; } printf("\n"); } return 0; } |