tim_534379341 @ 2021-08-13 11:56:41
#include <stdio.h>
int main(){
int n;
scanf("%d", &n);
int m;
scanf("%d", &m);
int k, x = 1;
for(k = 0; k<n-1; k++){
x = x * 10;
}
//对数字串每位数字的提取方法如下:
int a[n];
for(k = 0; k<n; k++){
int S = m / x;
a[k] = S % 10;
x = x / 10;
}
//用数表构建显示屏,1代表"X",0代表"."
int b[5] [1005];
int i;
for(k = 0; k < 5; k++){
for(i = 0; i < (4*n-1); i++){
b[k][i] = 0;
}
}
for(k = 0; k < n; k++){
switch(a[k]){
case 0:
for(i=0; i<5; i++){
b[i][4*k] = 1;
b[i][4*k+2] = 1;
}
b[0][4*k+1] = 1;
b[4][4*k+1] = 1;
break;
case 1:
for(i = 0; i < 5; i++){
b[i][4*k+2] = 1;
}
break;
case 2:
for(i = 4*k; i < (4*k +3); i++){
b[0][i] = 1;
b[2][i] = 1;
b[4][i] = 1;
}
b[1][4*k+2] = 1;
b[3][4*k] = 1;
break;
case 3:
for(i = 4*k; i < (4*k +3); i++){
b[0][i] = 1;
b[2][i] = 1;
b[4][i] = 1;
}
b[1][4*k+2] = 1;
b[3][4*k+2] = 1;
break;
case 4:
for(i = 0; i < 3; i++){
b[i][4*k] = 1;
}
for(i = 0; i < 5; i++){
b[i][4*k+2] = 1;
}
b[2][4*k+1] = 1;
break;//每段case分支别忘加break
case 5:
for(i = 4*k; i < (4*k +3); i++){
b[0][i] = 1;
b[2][i] = 1;
b[4][i] = 1;
}
b[1][4*k] = 1;
b[3][4*k+2] = 1;
break;
case 6:
for(i = 4*k; i < (4*k +3); i++){
b[0][i] = 1;
b[2][i] = 1;
b[4][i] = 1;
}
b[1][4*k] = 1;
b[3][4*k+2] = 1;
b[3][4*k] = 1;
break;
case 7:
for(i = 0; i < 5; i++){
b[i][4*k+2] = 1;
}
b[0][4*k] = 1;
b[0][4*k+1] = 1;
break;
case 8:
for(i = 4*k; i < (4*k +3); i++){
b[0][i] = 1;
b[2][i] = 1;
b[4][i] = 1;
}
b[1][4*k] = 1;
b[3][4*k+2] = 1;
b[3][4*k] = 1;
b[1][4*k+2] = 1;
break;
default:
for(i = 4*k; i < (4*k +3); i++){
b[0][i] = 1;
b[2][i] = 1;
b[4][i] = 1;
}
b[1][4*k] = 1;
b[3][4*k+2] = 1;
b[1][4*k+2] = 1;
}
}
//输出结果
for(k = 0; k < 5; k++){
for(i = 0; i < (4*n-1); i++){
if(b[k][i]){
printf("X");
} else{
printf(".");
}
}
printf("\n");
}
return 0;
}