当你被面试官要求用 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.
代码实现:
import java.io.*;
import java.util.ArrayList;
/**
* @author yx
* @date 2022-07-28 23:22
*/
public class Main {
static PrintWriter out=new PrintWriter(System.out);
static BufferedReader ins=new BufferedReader(new InputStreamReader(System.in));
static StreamTokenizer in=new StreamTokenizer(ins);
public static void main(String[] args) throws IOException {
String[] nums=new String[182];
for (int i = 0; i < 182; i++) {
nums[i]=ins.readLine();
}
char[] s=ins.readLine().toCharArray();
// System.out.println(s);
ArrayList<String> list=new ArrayList<>();
StringBuilder sb=new StringBuilder();
for (int i = 0; i < s.length; i++) {
if(s[i]>='A'&&s[i]<='Z'){
sb.append(s[i]);
if(i==s.length-1){
list.add(sb.toString());
}
}else {
if(sb.toString().equals("")){
continue;
}
// System.out.println(sb.toString());
list.add(sb.toString());
sb=new StringBuilder("");
}
}
// System.out.println(list.get(0));
// System.out.println(list.get(1));
for (int i = 0; i < list.size()-1; i++) {
String ss=list.get(i);
int length=ss.length();
for (int k = 0; k < 7; k++) {
for (int j = 0; j < length-1; j++) {
out.print(nums[(ss.charAt(j)-'A')*7+k]+" ");
}
out.println(nums[(ss.charAt(length-1)-'A')*7+k]);
}
out.println();
}
String ss=list.get(list.size()-1);
int length=ss.length();
for (int k = 0; k < 7; k++) {
for (int j = 0; j < length-1; j++) {
out.print(nums[(ss.charAt(j)-'A')*7+k]+" ");
}
out.println(nums[(ss.charAt(length-1)-'A')*7+k]);
}
out.flush();
}
}