PTA_1164 Good in C_模拟
1164 Good in C
分数 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
// PTA_1164 Good in C_模拟
#include<bits/stdc++.h>
using namespace std;
queue<string> q;
const int N=33;
char mp[N][N][N];
int main()
{
string s,tt;
int i,j,k,pos;
for( i=0;i<26;i++ )
for( j=1;j<=7;j++ )
for( k=1;k<=5;k++ )
cin>>mp[i][j][k];
getline( cin,s ); // 吸收回车
getline( cin,s ); // 空格分隔的单词 cin读取不完整
tt="";
for( i=0;i<s.size();i++ )
{
if( s[i]>='A' && s[i]<='Z' ) tt+=s[i];
else
{
if( tt!="" ) q.push( tt ); // 不为空才加入
tt="";
}
}
if( tt!="" ) q.push( tt );
while( q.size()!=1 )
{
tt=q.front(); q.pop();
for( j=1;j<=7;j++ )
{
for( pos=0;pos<tt.size();pos++ )
{
if( pos ) putchar(' '); // 处理单词结尾空格
for( k=1;k<=5;k++ )
cout<<mp[tt[pos]-'A'][j][k];
}
putchar('\n');
}
putchar('\n');
}
tt=q.front(); q.pop(); // 处理输出结尾空行
for( j=1;j<=7;j++ )
{
for( pos=0;pos<tt.size();pos++ )
{
if( pos ) putchar(' ');
for( k=1;k<=5;k++ )
cout<<mp[tt[pos]-'A'][j][k];
}
putchar('\n');
}
return 0;
}