1164 Good in C – PAT甲级真题

When your interviewer asks you to write “Hello World” using C, can you do as the following figure shows?

Input Specification:

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.

Output Specification:

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.

Sample Input:

Sample Output:

题目大意:输入首先给出26个英文大写字母A-Z,每个字母用7×5的、由C和.组成的矩阵构成。最后在一行中给出一个句子,以回车结束。句子是由若干个单词(每个包含不超过10个连续的大写英文字母)组成的,单词间以任何非大写英文字母分隔。题目保证至少给出一个单词。输出要求:对于每个单词,将其中每个字母用矩阵形式在一行中输出,字母间有一列空格分隔。单词的首尾不得有多余空格。相邻的两个单词间必须有一空行分隔。输出的首尾不得有多余空行。
分析:三维数组a中储存26个字母对应的图形矩阵,out中储存每行要输出的图形矩阵,同时初始化out所有元素为空格。字符串中可能存在乱七八糟的字符,所以用getline做句子的输入。句子的单词间以任何非大写字母分隔,用while循环遍历找到下标j为非大写字母所在下标,i为当前单词首下标,然后根据单词中每一个字母,将输出图形记录到out中,最后输出out数组~flag用来标记之前是否输出过一个单词,如果输出过,flag=1,则当再次需要输出单词之前需要先输出一个’\n’~

❤ 点击这里 -> 订阅《PAT | 蓝桥 | LeetCode学习路径 & 刷题经验》by 柳婼

❤ 点击这里 -> 订阅《从放弃C语言到使用C++刷算法的简明教程》by 柳婼

❤ 点击这里 -> 订阅PAT甲级乙级、蓝桥杯、GPLT天梯赛、LeetCode题解离线版