2013秋13级预备队集训练习2 --C - Automatic Poetry
来源:互联网 发布:linux网络yum源 编辑:程序博客网 时间:2024/05/16 09:00
Problem I
Automatic Poetry
Input: standard input
Output: standard output
Time Limit: 2 seconds
Memory Limit: 32 MB
“Oh God”, Lara Croft exclaims, “it’s one of these dumb riddles again!”
In Tomb Raider XIV, Lara is, as ever, gunning her way through ancient Egyptian pyramids, prehistoric caves and medival hallways. Now she is standing in front of some important Germanic looking doorway and has to solve a linguistic riddle to pass. As usual, the riddle is not very intellectually challenging.
This time, the riddle involves poems containing a “Schuttelreim”. An example of a Schuttelreim is the following short poem:
Ein Kind halt seinen Schnabel nur,
wenn es hangt an der Nabelschnur.
/*German contestants please forgive me. I had to modify something as they were not appearing correctly in plain text format*/
A Schuttelreim seems to be a typical German invention. The funny thing about this strange type of poetry is that if somebody gives you the first line and the beginning of the second one, you can complete the poem yourself. Well, even a computer can do that, and your task is to write a program which completes them automatically. This will help Lara concentrate on the “action” part of Tomb Raider and not on the “intellectual” part.
Input
The input will begin with a line containing a single number n. After this line follow n pairs of lines containing Schuttelreims. The first line of each pair will be of the form
s1<s2>s3<s4>s5
where the si are possibly empty, strings of lowercase characters or blanks. The second line will be a string of lowercase characters or blanks ending with three dots “...”. Lines will we at most 100 characters long.
Output
For each pair of Schuttelreim lines l1 and l2 you are to output two lines c1 and c2 in the following way: c1 is the same as l1 only that the bracket marks “<” and “>” are removed. Line c2 is the same as l2 , except that instead of the three dots the string s4s3s2s5 should appear.
Sample Input
3
ein kind haelt seinen <schn>abel <n>ur
wenn es haengt an der ...
weil wir zu spaet zur <>oma <k>amen
verpassten wir das ...
<d>u <b>ist
...
Sample Output
ein kind haelt seinen schnabel nur
wenn es haengt an der nabel schnur
weil wir zu spaet zur oma kamen
verpassten wir das koma amen
du bist
bu dist
#include <stdio.h>#include <string.h>int main(){ int i , n , l_s1 , l_s2 , l_s3 , l_s4 , l_s5 , l ; char s1[102] , s2[102] , s3[102] , s4[102] , s5[102] , s[102] ; scanf("%d", &n); getchar(); for(i = 1 ; i <= n ; i++) { for(l_s1 = 0 ; s1[l_s1-1]!='<' ; l_s1++) scanf("%c", &s1[l_s1]); s1[l_s1-1] = '\0'; for(l_s2 = 0 ; s2[l_s2-1]!='>' ; l_s2++) scanf("%c", &s2[l_s2]); s2[l_s2-1] = '\0'; for(l_s3 = 0 ; s3[l_s3-1]!='<' ; l_s3++) scanf("%c", &s3[l_s3]); s3[l_s3-1] = '\0'; for(l_s4 = 0 ; s4[l_s4-1]!='>' ; l_s4++) scanf("%c", &s4[l_s4]); s4[l_s4-1] = '\0'; gets(s5); gets(s); l_s5 = strlen(s5); s5[l_s5] = '\0'; l = strlen(s) ; s[l-3] ='\0'; if(s1[0]!= '\0') printf("%s", s1); if(s2[0]!= '\0') printf("%s", s2); if(s3[0]!= '\0') printf("%s", s3); if(s4[0]!= '\0') printf("%s", s4); if(s5[0]!= '\0') printf("%s", s5); printf("\n"); if(s[0]!='\0') printf("%s", s); if(s4[0]!= '\0') printf("%s", s4); if(s3[0]!= '\0') printf("%s", s3); if(s2[0]!= '\0') printf("%s", s2); if(s5[0]!= '\0') printf("%s", s5); printf("\n"); } return 0;}
- 2013秋13级预备队集训练习2 --C - Automatic Poetry
- 2013秋13级预备队集训练习2 --A - Palindromes
- 2013秋13级预备队集训练习4 --B - Steps
- 2013秋13级预备队集训练习1 C - Ecological Premium
- 2013秋13级预备队集训练习3 --C - Cube painting
- 2013秋13级预备队集训练习4 --C - The Land of Justice
- 2013秋13级预备队集训练习3 --E - The ? 1 ? 2 ? ... ? n = k problem
- 2013秋13级预备队集训练习2 --D - Artificial Intelligence?
- 2013秋13级预备队集训练习2 --H - Immediate Decodability
- 2013秋13级预备队集训练习1 A - Hashmat the Brave Warrior
- 2013秋13级预备队集训练习1 B - Back to High School Physics
- 2013秋13级预备队集训练习1 D - The Decoder
- 2013秋13级预备队集训练习1 E - Kindergarten Counting Game
- 2013秋13级预备队集训练习1 F - Machined Surfaces
- 2013秋13级预备队集训练习1 G - Rotating Sentences
- 2013秋13级预备队集训练习1 H - Marvelous Mazes
- 2013秋13级预备队集训练习1 I - Triangle Wave
- 2013秋13级预备队集训练习1 J - Hangman Judge
- sharepoint 读取 list folder
- 每个软件工程师都应该尝试的5件事情
- 二分法求单峰函数最大值
- 云计算笔记
- MySQL CLUSTER(MySQL集群)初步
- 2013秋13级预备队集训练习2 --C - Automatic Poetry
- Android之获取手机屏幕大小
- cocos2dx 学习
- MFC不能多线程操作控件的原因
- Knockoutjs介绍
- 字符集编解码的故事(ASCII,ANSI,Unicode,Utf-8)
- 神经网络(一)
- emgucv mean shift
- Hive create external table partition关联数据文件