“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. 1205. By the Underground or by Foot?(spfa)

    1205 简单题 有一些小细节 两个站可能不相连 但是可以走过去 #include <iostream> #include<cstdio> #include<cstrin ...

  2. 函数buf_pool_get

    根据space ,offset 获取 buff pool的实例 下标 /**************************************************************** ...

  3. 4197: [Noi2015]寿司晚宴

    状压dp. 500分解质因数的话,除了最大的质因数只需要8个质数,用二进制x储存,最大的质因数用y来储存(若没有比那8个质数大的质因数就使y=1) 用f[i][j]表示第一个人方案为i,第二个人方案为 ...

  4. vs2008 编译时候 自动关闭 问题解决方法

    最近又出现如此让人崩溃的问题.      vs2008在编译程序时候老是莫名其妙的自动退出.卸载重装以后问题仍然存在.      害我一度以为是vs2008的BUG,看网上说的更新BUG.      ...

  5. CodePage代码,MultiByteToWideChar

    Identifier .NET Name Additional information 37 IBM037 IBM EBCDIC US-Canada 437 IBM437 OEM United Sta ...

  6. 结合daterangepicker实现Datatables表格带参数查询

    http://dt.thxopen.com/example/user_share/send_extra_param.html#@一颗树 http://www.guoxk.com/node/jquery ...

  7. poj 1201/zoj 1508 intervals 差分约束系统

      // 思路 : // 图建好后 剩下的就和上一篇的 火烧连营那题一样了 求得解都是一样的 // 所以稍微改了就过了 // 最下面还有更快的算法 速度是这个算法的2倍#include <ios ...

  8. Oracle中job的使用详解

    我们在项目开发中,常常会有一些复杂的业务逻辑.使用oracle的存储过程,可以大大减少java程序代码的编写工作量,而且存储过程执行在数据库上,这样可以利用oracle的良好性能支持,极大地提高程序执 ...

  9. CKEditor如何统计文字数量

    今天在修改v5后台的比赛系统时,发现文本框需要限制输入字数.我们这个系统用的是3.6.3版本的,前台代码是这样的 <script> //编辑器 CKEDITOR.replace('matc ...

  10. linux下利用backtrace追踪函数调用堆栈以及定位段错误

    一般察看函数运行时堆栈的方法是使用GDB(bt命令)之类的外部调试器,但是,有些时候为了分析程序的BUG,(主要针对长时间运行程序的分析),在程序出错时打印出函数的调用堆栈是非常有用的. 在glibc ...