7-1 Good in C (20分)

7-1 Good in C (20分)

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

7-1 Good in C (20分)

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×5matrix 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.

 

#include<iostream>
#include<algorithm>
#include<vector> 
#include<map>
using  namespace std;
struct Martix{
	   string a[8]; 
}m; 
 
vector< struct Martix > v( 27 );
struct Martix add(struct Martix a ,struct Martix b  ){
       struct Martix ans;       
	   for( int i=1;i<=7;i++){
       	    ans.a[i] = a.a[i] + " " + b.a[i]; 
	   }	
	   return ans;
} 
bool   flag = false;
void   output( string s ){
	   struct Martix ans ;
	   for( int i=0;i<s.length();i++){
	   	    int idx = s[i] - 'A';
			if( i ==0 )
			    ans = v[idx];	 
			else {
				m   = v[idx];
				ans = add( ans , m ); 
			}  	    
	   } 
	   if(  flag )
	        cout<<endl;
	   else flag = true;
	   for( int i=1;i<=7;i++){
	   	    cout<<ans.a[i]<<endl;
	   } 
}
int main(void){
	//问题在于,如何存储
	//这26个英文字母
	//7*5的矩阵 
	for( int i=0;i<26;i++){
		 for( int j=1;j<=7;j++){
		 	  cin>>v[i].a[j];
		 }
	}
	string s,t="";
    getchar();
	getline(cin,s);
	//这个题的关键在于输出。
	
	for( int i=0;i<s.length();i++){
		 if( s[i] >='A' && s[i] <= 'Z'){
		     t+=s[i];  
		 }  
		 else {
             if( t.length()!=0 )
		 	     output( t );
		     t="";
		 }
	}    
	if( t.length() !=0 )
	    output( t ); 
	return 0;
} 

 

7-1 Good in C (20分)7-1 Good in C (20分) ~ 知至~ 发布了778 篇原创文章 · 获赞 139 · 访问量 9万+ 他的留言板 关注
上一篇:分享34个国内外免费临时手机号码网站


下一篇:第六届天梯赛CCCC 题解