分数 20
全屏浏览题目
切换布局
作者 陈越
单位 浙江大学
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:
..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!
Sample Output:
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.
代码长度限制
16 KB
时间限制
400 ms
内存限制
64 MB
#include<bits/stdc++.h>
using namespace std;
int main(){
#ifdef ONLINE_JUDGE
#else
//freopen("1.txt","r",stdin);
#endif
char v[26][7][5];
for(int i=0;i<26;i++)//输入26个大写字母
for(int j=0;j<7;j++)
for(int k=0;k<5;k++)
cin>>v[i][j][k];
getchar();//吸收换行符
string s;
getline(cin,s);//可能出现空格用getline读取
int flag=0;//用于每个单词输出完的换行符的输出
for(int i=0;i<s.size();i++){//遍历输入的字符串
int k=i;//从当前位置开始找第一个单词
string t;//记录该单词
while(s[k]>='A'&&s[k]<='Z'){//把从k开始遇到的所有大写字母记作一个单词
t+=s[k];
k++;
}
i=k;//找下一个单词
if(t.size()){//如果这是个单词
if(flag)cout<<endl;//如果遇到超过一个单词,从第二个单词开始都先输出一个换行符
else flag=1;//如果是第一个单词则将标志位记为1,表示已经遇到过一个单词了
}
if(t.size())//如果这是一个单词
for(int j=0;j<7;j++){//输出这个单词
bool space=false;//用于字母间的空格输出,并防止行末空格
for(int l=0;l<t.size();l++){//遍历这个单词的各字母
int pos=t[l]-'A';//取这个字母在三位数组v中的位置
if(space)cout<<' ';//如果不是第一个字母则要输出空格
else space=true;//否则标记为已经有一个字母
for(int k=0;k<5;k++)cout<<v[pos][j][k];//输出这个字母的第一行
}
cout<<endl;//输出这个单词的第一行之后要输出换行
}
}
return 0;
}