“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. C/C++内存存储

    #include <stdio.h> #include "string.h" #include "malloc.h" void Swap(int a ...

  2. 信息:Could not publish server configuration for Tomcat v6.0 Server at localhost. Multiple Context

    需要把server.xml更正一下,去掉重复的context.或者把整个server文件夹都删掉,重新添加服务器.也可以在server窗口中删除server,再新添加一个server.

  3. POJ 2449 A*+SPFA

    A*算法求第k短路流程: 1)计算h[],即当前点到t的估计值 若为有向图,建立反向图求出h[].若为无向图,可直接求解h[].可通过SPFA求解. 2)A*搜索 每次找到新节点就直接加入队列,计算出 ...

  4. 利用序列化的方式实现C#深复制和浅复制

    代码如下:具体看注释 [Serializable] public class A { public virtual string Name { get; set; } public int Age { ...

  5. 强势解决:windows 不能在本地计算机中起动Tomcat参考特定错误代码1

    Tomcat添加系统服务:service.bat install 启动本服务的时候却提示“windows 不能在本地计算机中起动 Apache Tomcat参考特定错误代码1,若不是Microsoft ...

  6. [反汇编练习] 160个CrackMe之011

    [反汇编练习] 160个CrackMe之011. 本系列文章的目的是从一个没有任何经验的新手的角度(其实就是我自己),一步步尝试将160个CrackMe全部破解,如果可以,通过任何方式写出一个类似于注 ...

  7. git - 搭建git仓库

    1. 更新git版本: http://codelife.me/blog/2013/06/25/upgrade-git-on-centos-6-4/ 2. 建立git仓库: git init --bar ...

  8. hdu 4435 charge-station

    // 题意 从1出发逛完N个点回到出发点 要在这N个点选择性建设加油站 车每次加满油最多可以行使D米// 然后最少要花多少钱才能达到上述要求// 注意到 第i个城市的花费是 2^(i-1) 所以 我就 ...

  9. Mac终端编译运行C++

    1.在编辑器中写好C++代码 2.打开终端打开文件对应的地址 3.用g++命令来编译.cpp文件 4.用./文件名来运行 观察文件的目录可发现 g++ 源文件名 编译源文件,产生a.out ./文件名 ...

  10. Oracle 跟踪事件 set event

    一.Oracle跟踪文件 Oracle跟踪文件分为三种类型,一种是后台报警日志文件,记录数据库在启动.关闭和运行期间后台进程的活动情况,如表空间创建.回滚段创建.某些alter命令.日志切换.错误消息 ...