When your interviewer asks you to write "Hello World" using C, can you do as the following figure shows?
Each input file contains one test case. For each case, the first part gives the 26 capital English letters A-Z, each in a 7×5 matrix of C
's and .
's. Then a sentence is given in a line, ended by a return. The sentence is formed by several words (no more than 10 continuous capital English letters each), and the words are separated by any characters other than capital English letters.
It is guaranteed that there is at least one word given.
For each word, print the matrix form of each of its letters in a line, and the letters must be separated by exactly one column of space. There must be no extra space at the beginning or the end of the word.
Between two adjacent words, there must be a single empty line to separate them. There must be no extra line at the beginning or the end of the output.
- ..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.
对每个单词,将其每个字母用矩阵形式在一行中输出,字母间有一列空格分隔。单词的首尾不得有多余空格。
相邻的两个单词间必须有一空行分隔。输出的首尾不得有多余空行。
- /*
- * @Author: Spare Lin
- * @Project: AcWing2022
- * @Date: 2022/6/29 11:12
- * @Description: AcWing 4276. 擅长C 来源:PAT甲级真题1164
- */
-
- #include <iostream>
-
- using namespace std;
-
- char g[26][7][6]; //输入单词 26个7*5的矩阵
- bool is_first = true;//判断是否是第一行
-
- void output(string word) { //输出每个单词
- if (word.empty()) return; //单词为空 不需要输出
-
- if(is_first) is_first = false; //如果是第一个单词则不输出换行 否则输出换行
- else cout << '\n';
-
- char str[7][60] = {0};
- for (int i = 0; i < word.size(); ++i) {
- //打印单词每个字母的 7*5矩阵
- for (int j = 0; j < 7; ++j) {
- for (int k = 0; k < 5; ++k) {
- //矩阵的行放在第j行 列应该为i * 6 + k
- str[j][i * 6 + k] = g[word[i] - 'A'][j][k];
- }
- }
- }
- //从第二个矩阵开始填充' '在每个矩阵的起始列前一个位置 即 i * 6 - 1
- for (int i = 1; i < word.size(); ++i) {
- for (int j = 0; j < 7; ++j) {
- str[j][i * 6 - 1] = ' ';
- }
- }
- for (int i = 0; i < 7; ++i) {
- cout << str[i] << '\n';
- }
- }
-
- int main() {
- for (int i = 0; i < 26; ++i) {
- for (int j = 0; j < 7; ++j) {
- cin >> g[i][j];
- }
- }
- cin.get(); //吸收换行
- string word, str;
- getline(cin, word);
- for (auto &x: word) {
- if (isupper(x)) {
- str += x;
- } else {
- output(str);
- str.clear();
- }
- }
- output(str); //最后可能还剩下一个单词
- return 0;
- }