“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. 清幽傲竹实现kbmMWServer的方法(转)

    感谢竹子! 整体思路,是不用kbmMWUNIDACQuery,而是直接用uniQuery做数据查询,利用kbmMWUNIDACConnectioPool取得数据库联接,自己再建一个uniQuery对象 ...

  2. poj 3468 A Simple Problem with Integers (线段树 成段更新 加值 求和)

    题目链接 题意: 只有这两种操作 C a b c" means adding c to each of Aa, Aa+1, ... , Ab. -10000 ≤ c ≤ 10000.&quo ...

  3. iOS开发:记录开发中遇到的编译或运行异常以及解决方案

    1.部署到真机异常 dyld`dyld_fatal_error: ->  0x120015088 <+0>: brk    #0x3 dyld: Library not loaded ...

  4. IIS Web负载均衡的几种方式

    Web负载均衡的几种实现方式 摘要:负载均衡(Load Balance)是集群技术(Cluster)的一种应用.负载均衡可以将工作任务分摊到多个处理单元,从而提高并发处理能力.目前最常见的负载均衡应用 ...

  5. PhoneGap 安装体验

    npm -v #显示版本,检查npm 是否正确安装. npm install express #安装express模块 npm install -g express #加上 -g 启用global安装 ...

  6. 给你一个承诺 - 玩转 AngularJS 的 Promise(转)

    在谈论Promise之前我们要了解一下一些额外的知识:我们知道JavaScript语言的执行环境是“单线程”,所谓单线程,就是一次只能够执行一个任务,如果有多个任务的话就要排队,前面一个任务完成后才可 ...

  7. Mybatis学习——一对多关联表查询

    1.实体类 public class Student { private int id; private String name; } public class Classes { private i ...

  8. 在delphi中, reintroduce作用

    在delphi中, reintroduce作用 当在子类中重载或者重新声明父类的虚方法时,使用     reintroduce   关键字告知编译器,可以消除警告信息.如:          TPar ...

  9. 【转】Intel HEX介绍

    记录格式 Intel HEX由任意数量的十六进制记录组成.每个记录包含5个域,它们按以下格式排列: :llaaaatt[dd...]cc 每一组字母对应一个不同的域,每一个字母对应一个十六进制编码的数 ...

  10. XA事务处理

    XA接口详解 X/Open XA接口是双向的系统接口,在事务管理器(Transaction Manager)以及一个或多个资源管理器(Resource Manager)之间形成通信桥梁.事务管理器控制 ...