当你被面试官要求用 C 写一个“Hello World”时,有本事像下图显示的那样写一个出来吗?
输入格式:
输入首先给出 26 个英文大写字母 A-Z,每个字母用一个 7×5 的、由 C 和 . 组成的矩阵构成。最后在一行中给出一个句子,以回车结束。句子是由若干个单词(每个包含不超过10个连续的大写英文字母)组成的,单词间以任何非大写英文字母分隔。
题目保证至少给出一个单词。
输出格式:
对每个单词,将其每个字母用矩阵形式在一行中输出,字母间有一列空格分隔。单词的首尾不得有多余空格。
相邻的两个单词间必须有一空行分隔。输出的首尾不得有多余空行。
输入样例:
..C..
.C.C.
C...C
CCCCC
C...C
C...C
C...C
CCCC.
C...C
C...C
CCCC.
C...C
C...C
CCCC.
.CCC.
C...C
C....
C....
C....
C...C
.CCC.
CCCC.
C...C
C...C
C...C
C...C
C...C
CCCC.
CCCCC
C....
C....
CCCC.
C....
C....
CCCCC
CCCCC
C....
C....
CCCC.
C....
C....
C....
CCCC.
C...C
C....
C.CCC
C...C
C...C
CCCC.
C...C
C...C
C...C
CCCCC
C...C
C...C
C...C
CCCCC
..C..
..C..
..C..
..C..
..C..
CCCCC
CCCCC
....C
....C
....C
....C
C...C
.CCC.
C...C
C..C.
C.C..
CC...
C.C..
C..C.
C...C
C....
C....
C....
C....
C....
C....
CCCCC
C...C
C...C
CC.CC
C.C.C
C...C
C...C
C...C
C...C
C...C
CC..C
C.C.C
C..CC
C...C
C...C
.CCC.
C...C
C...C
C...C
C...C
C...C
.CCC.
CCCC.
C...C
C...C
CCCC.
C....
C....
C....
.CCC.
C...C
C...C
C...C
C.C.C
C..CC
.CCC.
CCCC.
C...C
CCCC.
CC...
C.C..
C..C.
C...C
.CCC.
C...C
C....
.CCC.
....C
C...C
.CCC.
CCCCC
..C..
..C..
..C..
..C..
..C..
..C..
C...C
C...C
C...C
C...C
C...C
C...C
.CCC.
C...C
C...C
C...C
C...C
C...C
.C.C.
..C..
C...C
C...C
C...C
C.C.C
CC.CC
C...C
C...C
C...C
C...C
.C.C.
..C..
.C.C.
C...C
C...C
C...C
C...C
.C.C.
..C..
..C..
..C..
..C..
CCCCC
....C
...C.
..C..
.C...
C....
CCCCC
HELLO~WORLD!
输出样例:
C...C CCCCC C.... C.... .CCC.
C...C C.... C.... C.... C...C
C...C C.... C.... C.... C...C
CCCCC CCCC. C.... C.... C...C
C...C C.... C.... C.... C...C
C...C C.... C.... C.... C...C
C...C CCCCC CCCCC CCCCC .CCC.
C...C .CCC. CCCC. C.... CCCC.
C...C C...C C...C C.... C...C
C...C C...C CCCC. C.... C...C
C.C.C C...C CC... C.... C...C
CC.CC C...C C.C.. C.... C...C
C...C C...C C..C. C.... C...C
C...C .CCC. C...C CCCCC CCCC.
|代码长度限制 | 时间限制 | 内存限制 |
| 16KB | 400ms | 64MB |
代码:
#include <bits/stdtr1c++.h>
using namespace std;
char a[26][7][5], out[7][100];
string s;
int main() {
for (int i = 0; i < 7; i++)
for (int j = 0; j < 100; j++)
out[i][j] = ' ';
for (int i = 0; i < 26; i++)
for (int j = 0; j < 7; j++)
for (int k = 0; k < 5; k++)
cin >> a[i][j][k];
getchar();
getline(cin, s);
for (int i = 0, j, flag = 0; i < int(s.size()); i++) {
j = i;
while (j < int(s.size()) && s[j] >= 'A' && s[j] <= 'Z') j++;
if (i == j) continue;
for (int k = i; k < j; k++)
for (int l = 0; l < 7; l++)
for (int m = 0; m < 5; m++)
out[l][m + (k - i) * 6] = a[s[k] - 'A'][l][m];
if (flag) cout << '\n';
for (int k = 0; k < 7; k++) {
flag = 1;
for (int l = 0; l < 6 * (j - i) - 1; l++) cout << out[k][l];
cout << '\n';
}
i = j;
}
return 0;
}
标签:...,20,..,....,CCCC,擅长,CCCCC,CCC,1109
From: https://www.cnblogs.com/Fare-well/p/16749640.html