Ultraviolet A 10361 automatic Poetry

Source: Internet
Author: User
Tags define local

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 your ent 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 injection. 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 blks. the second line will be a string of lowercase characters or blanks ending with three dots "... ". lines will we at most 100 characters long.

Outputfor 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, should t that instead of the three dots the string s4s3s2s5 shoshould 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

 

This is a very simple string processing question. I set the third parameter of the cin. Getline () function to take Si.

Pay attention to the three '.' after the second string. Nothing else can be said.

 1 //#define LOCAL 2 #include <iostream> 3 #include <cstdio> 4 #include <cstring> 5 using namespace std; 6  7 const int maxn = 105; 8 char s1[5][maxn]; 9 char s2[maxn];10 11 int main(void)12 {13     #ifdef LOCAL14         freopen("10361in.txt", "r", stdin);15     #endif16     int N, i;17     scanf("%d", &N);18     while(N--)19     {20         memset(s1, 0, sizeof(s1));21         getchar();22         cin.getline(s1[0], maxn, ‘<‘);23         cin.getline(s1[1], maxn, ‘>‘);24         cin.getline(s1[2], maxn, ‘<‘);25         cin.getline(s1[3], maxn, ‘>‘);26         cin.getline(s1[4], maxn);27         for(i = 0; i < 5; ++i)28         {29             cout << s1[i];30         }31         cout << endl;32         33         cin.getline(s2, maxn, ‘.‘);34         getchar();35         getchar();36         cout << s2 <<s1[3] << s1[2] << s1[1] << s1[4] << endl;37         38     }39     return 0;40 }
Code Jun

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.