UVA 10361-automatic Poetry (analogue)

Source: Internet
Author: User

Automatic poetryTime limit:MS Memory Limit:0KB 64bit IO Format:%lld & %llu Submit Status

Description

Problem I

Automatic poetry

Input: Standard Input

Output: Standard Output

Time Limit: 2 seconds

Memory Limit: MB

"Oh God", Lara Croft exclaims, "It's one of these dumb riddles again!"

In Tomb raider XIV, Lara are, as ever, gunning her to through ancient Egyptian pyramids, prehistoric caves and Medival HAL Lways. Now she's standing in front of some important Germanic looking doorway and have 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 are 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 is appearing correctly in plain text format*/

A Schuttelreim seems to be a typical German invention. The funny thing about this strange type of poetry are if somebody gives you the first line and the beginning of the SE Cond one, you can complete the poem yourself. Well, even a computer can does, and your task is to write a program which completes them automatically. This would help Lara concentrate on the "action" part of Tomb Raider and is on the "intellectual" part.

Input

The input would 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 would be of the form

S1<s2>s3<s4>s5

Where the SI is possibly empty, strings of lowercase characters or blanks. The second line would be a string of lowercase characters or blanks ending with three dots "...". Lines would we at the most characters long.

Outputfor each pair of Schuttelreim lines L1 and L2 "is" to output the "lines C1 and C2 in the following Way:c1" is the Same as L1 only then the bracket marks "<" and ">" are removed. Line C2 are 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


Test instructions: Input n set of data, each set of data consists of two strings

The input format of the first string is S1<S2>S3<S4>S5

The input format of the second string is C ...

Then output

The output of the first string is S1S2S3S4S5

The output of the second string is CS4S3S2S5


#include <stdio.h> #include <string.h> #include <stdlib.h> #include <algorithm>using namespace    Std;char Str[5][110];int Main () {int t,i,j,cnt;    int len1,len2;    Char a[110],b[110];    Char c[110];        while (~SCANF ("%d", &t)) {GetChar ();            while (t--) {gets (a);            Gets (b);            Len1=strlen (a);            memset (str,0,sizeof (str));            Memset (C,0,sizeof (c));            cnt=0;                for (i=0;a[i]!= ' < '; i++) {str[0][cnt]=a[i];            cnt++;            } str[0][cnt]= ' + ';            cnt=0;                for (i=i+1;a[i]!= ' > '; i++) {str[1][cnt]=a[i];            cnt++;            } str[1][cnt]= ' + ';            cnt=0;                for (i=i+1;a[i]!= ' < '; i++) {str[2][cnt]=a[i];            cnt++;            } str[2][cnt]= ' + ';            cnt=0;  for (i=i+1;a[i]!= ' > '; i++)          {Str[3][cnt]=a[i];            cnt++;            } str[3][cnt]= ' + ';            cnt=0;                for (i=i+1;i<len1;i++) {str[4][cnt]=a[i];            cnt++;            } str[4][cnt]= ' + ';            cnt=0; for (j=0;b[j]!= '. ';                J + +) {C[cnt]=b[j];            cnt++;            } c[cnt]= ' + ';            for (i=0;i<5;i++) printf ("%s", Str[i]);            printf ("\ n");        printf ("%s%s%s%s%s\n", c,str[3],str[2],str[1],str[4]); }} return 0;}


UVA 10361-automatic Poetry (analogue)

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.