hhh21g @ 2023-10-27 17:10:27
#include <stdio.h>
int main()
{
int num[6][500] = { 0 };
int n;
int i = 0, j = 0, k = 0;
char a[100];
scanf("%d", &n);
getchar();
for (i = 0; i < n; i++) {
scanf("%c", &a[i]);
}
for (i = 0, j = 0; i < n; i++, j += 4) {
if (a[i] == '2' || a[i] == '3' || a[i] == '5' || a[i] == '6' || a[i] == '8' || a[i] == '9') {
k = 0;
for (k = 0; k < 3; k++) {
num[0][k + j] = 1;
num[2][k + j] = 1;
num[4][k + j] = 1;
}
if (a[i] == '2' || a[i] == '3' || a[i] == '8' || a[i] == '9') {
num[1][j + 2] = 1;
}
if (a[i] == '3' || a[i] == '5' || a[i] == '6' || a[i] == '8' || a[i] == '9') {
num[3][j + 2] = 1;
}
if (a[i] == '5' || a[i] == '6' || a[i] == '8' || a[i] == '9') {
num[1][j] = 1;
}
if (a[i] == '2' || a[i] == '6' || a[i] == '8') {
num[3][j] = 1;
}
}
else if (a[i] == '0' || a[i] == '1' || a[i] == '4' || a[i] == '7') {
k = 0;
for (k = 0; k < 5; k++) {
num[k][j + 2] = 1;
}
if (a[i] == '0') {
k = 0;
for (k = 0; k < 3; k++) {
num[0][k + j] = 1;
num[4][k + j] = 1;
}
for (k = 0; k < 4; k++) {
num[k][j] = 1;
}
}
if (a[i] == '4') {
k = 0;
for (k = 0; k < 3; k++) {
num[k][j] = 1;
num[2][k + j] = 1;
}
}
if (a[i] == '7') {
k = 0;
for (k = 0; k < 3; k++) {
num[0][k + j] = 1;
}
}
}
}i = 0; j = 0;
for (i = 0; i < 5; i++) {
for (j = 0; j < (4 * n - 1); j++) {
if (num[i][j] == 1) printf("X");
else printf(".");
}
printf("\n");
}
return 0;
}
by hhh21g @ 2023-10-28 10:48:20
根据别讨论区的大佬提示把scanf("%d")和getchar()改成了scanf("%d\n")通过了 供大家参考