“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<iostream>
#include<string.h>
#include<stdio.h>
#include<ctype.h>
#include<algorithm>
#include<stack>
#include<queue>
#include<set>
#include<math.h>
#include<vector>
#include<map>
#include<deque>
#include<list>
using namespace std;
char a[120],b[120];
int la,lb;
int i,j;
int main()
{
int test;
scanf("%d",&test);
getchar();
while(test--)
{
memset(a,0,sizeof(a));
memset(b,0,sizeof(b));
gets(a);
gets(b);
la=strlen(a);
lb=strlen(b);
for(i=0; i<la; i++)
{
if(a[i]!='<'&&a[i]!='>')
printf("%c",a[i]);
}
printf("\n");
for(i=0; i<lb-1; i++)
{
if(b[i]!='.')
printf("%c",b[i]);
}
int positionl;
int positionr;
for(i=0; i<la; i++)
{
if(a[i]=='<')
positionl=i+1;
if(a[i]=='>')
positionr=i-1;
}
for(j=positionl; j<=positionr; j++)
printf("%c",a[j]);
// printf("*******");
for(i=la-1; i>=0; i--)
{
if(a[i]=='>')
{
positionl=i+1;
}
}
for(i=0; i<la; i++)
{
if(a[i]=='<')
{
positionr=i-1;
}
}
for(j=positionl; j<=positionr; j++)
printf("%c",a[j]);
// printf("*******");
for(i=la-1; i>=0; i--)
{
if(a[i]=='<')
positionl=i+1;
if(a[i]=='>')
positionr=i-1;
}
for(j=positionl; j<=positionr; j++)
printf("%c",a[j]);
// printf("*******");
for(i=0; i<la; i++)
{
if(a[i]=='>')
positionl=i+1;
}
for(j=positionl; j<la; j++)
printf("%c",a[j]);
printf("\n");
}
return 0;
}

UVA10361 - Automatic Poetry的更多相关文章

  1. UVa 10361 Automatic Poetry

    Automatic Poetry Input: standard input Output: standard output Time Limit: 2 seconds Memory Limit: 3 ...

  2. UVA10361 -自动作诗机

    UVA10361 - Automatic Poetry(自动作诗机) A Schuttelreim seems to be a typical German invention. The funny ...

  3. UVA大模拟代码(白书训练计划1)UVA 401,10010,10361,537,409,10878,10815,644,10115,424,10106,465,10494

    白书一:http://acm.hust.edu.cn/vjudge/contest/view.action?cid=64609#overview 注意UVA没有PE之类的,如果PE了显示WA. UVA ...

  4. UVA题目分类

    题目 Volume 0. Getting Started 开始10055 - Hashmat the Brave Warrior 10071 - Back to High School Physics ...

  5. 刘汝佳 算法竞赛-入门经典 第二部分 算法篇 第五章 1(String)

    第一题:401 - Palindromes UVA : http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8 ...

  6. Volume 1. String(uva)

    10361 - Automatic Poetry #include <iostream> #include <string> #include <cstdio> # ...

  7. APIPA(Automatic Private IP Addressing,自动专用IP寻址)

    APIPA APIPA(Automatic Private IP Addressing,自动专用IP寻址),是一个DHCP故障转移机制.当DHCP服务器出故障时, APIPA在169.254.0.1到 ...

  8. [SharePoint 2013] Automatic deployment script

    Implement automatic deployment through windows task. Add-PsSnapin Microsoft.SharePoint.PowerShell $t ...

  9. JSONKit does not support Objective-C Automatic Reference Counting(ARC) / ARC forbids Objective-C objects in struct

    当我们在使用JSONKit处理数据时,直接将文件拉进项目往往会报这两个错“JSONKit   does not support Objective-C Automatic Reference Coun ...

随机推荐

  1. 让Eclipse和NetBeans共享同一个项目

    有的时候,我们会下载一些源代码来学习研究,但是下载下来的工程文件是eclipse的或者是NetBeans的.如果手头上没有eclipse或者没有 NetBeans,或只有其中一个怎么办?又或者,你习惯 ...

  2. hdu 1575 Tr A (矩阵快速幂入门题)

    题目 先上一个链接:十个利用矩阵乘法解决的经典题目 这个题目和第二个类似 由于矩阵乘法具有结合律,因此A^4 = A * A * A * A = (A*A) * (A*A) = A^2 * A^2.我 ...

  3. bzoj1975

    显然是类似k短路,直接不停增广即可 好久没写A*了,裸的A*可能会TLE 加点剪枝就卡过去了……… type node=record po,next:longint; cost:double; end ...

  4. 在win7系统下使用TortoiseGit(乌龟git)简单操作Git@OSC

    非常感谢OSC提供了这么好的一个国内的免费的git托管平台.这里简单说下TortoiseGit操作的流程.很傻瓜了 首先你要准备两个软件,分别是msysgit和tortoisegit,乌龟还可以在下载 ...

  5. 推荐 15 个 Angular.js 应用扩展指令(参考应用)

    几天前我们看到Angular 1.4.0发布了-一个以社团为驱动的发布版本涵盖了400多个GitHub的提交,增加了对特性的提升,比如动画,以及可用性. 官方新闻发布稿 覆盖了绝大部分,这同样值得放于 ...

  6. Library cache lock/pin详解

    Library cache lock/pin 一.概述 ---本文是网络资料加metalink 等整理得来一个实例中的library cache包括了不同类型对象的描述,如:游标,索引,表,视图,过程 ...

  7. (3)Spring定时任务的几种实现

    Spring定时任务的几种实现 近日项目开发中需要执行一些定时任务,比如需要在每天凌晨时候,分析一次前一天的日志信息,借此机会整理了一下定时任务的几种实现方式,由于项目采用spring框架,所以我都将 ...

  8. Android Studio进行NDK编程

  9. Oracle DBA 的常用Unix参考手册(一)

    作为一名Oracle DBA,在所难免要接触Unix,但是Unix本身又是极其复杂的,想要深刻掌握同样很不容易.那么到底我们该怎么入手呢?Donald K Burleson 的<Unix for ...

  10. Android-AnimationDrawable(三)运行的几种方式

    项目开发用到了AnimationDrawable,调用start后没有运行,很纳闷.google搜了下.记录一下. 这个AnimationDrawable.start不能直接写在onClick,onS ...