Shy_Vector @ 2024-08-10 19:41:32
#include <iostream>
using namespace std;
const int dig[5][10] = {
{0b111, 0b001, 0b111, 0b111, 0b101, 0b111, 0b111, 0b111, 0b111, 0b111},
{0b101, 0b001, 0b001, 0b001, 0b101, 0b100, 0b100, 0b001, 0b101, 0b101},
{0b101, 0b001, 0b111, 0b111, 0b111, 0b111, 0b111, 0b001, 0b111, 0b111},
{0b101, 0b001, 0b100, 0b001, 0b001, 0b001, 0b101, 0b001, 0b101, 0b001},
{0b111, 0b001, 0b111, 0b111, 0b001, 0b111, 0b111, 0b001, 0b111, 0b111}
};
int main() {
int n, nums[100];
cin >> n;
getchar();
for (int i = 0; i < n; i++) {
nums[i] = getchar() - '0';
}
for (int i = 0; i < 5; i++) {
for (int j = 0; j < n; j++) {
if (j != 0) {
putchar('.');
}
int tmp = dig[i][nums[j]] << 29;
for (int k = 0; k < 3; k++) {
if (tmp & (1 << 31)) {
putchar('X');
} else {
putchar('.');
}
tmp <<= 1;
}
}
putchar('\n');
}
return 0;
}
/*
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
*/
/*
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
*/
by Shy_Vector @ 2024-08-10 19:43:18
第一个getchar()是用来吸掉cin后第一个'\n'
by ikunTLE @ 2024-08-10 19:46:32
@Shy_Vector 换行符问题,是\r\n
,改后:
#include <iostream>
using namespace std;
const int dig[5][10] = {
{0b111, 0b001, 0b111, 0b111, 0b101, 0b111, 0b111, 0b111, 0b111, 0b111},
{0b101, 0b001, 0b001, 0b001, 0b101, 0b100, 0b100, 0b001, 0b101, 0b101},
{0b101, 0b001, 0b111, 0b111, 0b111, 0b111, 0b111, 0b001, 0b111, 0b111},
{0b101, 0b001, 0b100, 0b001, 0b001, 0b001, 0b101, 0b001, 0b101, 0b001},
{0b111, 0b001, 0b111, 0b111, 0b001, 0b111, 0b111, 0b001, 0b111, 0b111}
};
int main() {
int n, nums[100];
cin >> n;
getchar();getchar();
for (int i = 0; i < n; i++) {
nums[i] = getchar() - '0';
}
for (int i = 0; i < 5; i++) {
for (int j = 0; j < n; j++) {
if (j != 0) {
putchar('.');
}
int tmp = dig[i][nums[j]] << 29;
for (int k = 0; k < 3; k++) {
if (tmp & (1 << 31)) {
putchar('X');
} else {
putchar('.');
}
tmp <<= 1;
}
}
putchar('\n');
}
return 0;
}
/*
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
*/
/*
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
*/
by Shy_Vector @ 2024-08-10 19:50:28
@ikunTLE 十分感谢!我用vscode写的,看来是vscode和洛谷的输入输出有些区别
by ikunTLE @ 2024-08-10 19:51:54
@Shy_Vector 不是,这个数据是在 Windows 环境下造的
by ikunTLE @ 2024-08-10 19:54:08
@Shy_Vector 你的代码是对的,是数据的问题
by Babadi_Baaa @ 2024-08-17 22:13:51
样例错了,你没有发现0和一之间多了一行吗?
by ccc08080 @ 2024-08-22 19:53:59
@Babadi_Baaa