博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
UVA —10361—Automatic Poetry
阅读量:3959 次
发布时间:2019-05-24

本文共 2732 字,大约阅读时间需要 9 分钟。

题目描述

“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.

The Problem

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
s1s3s5
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 abel ur
wenn es haengt an der …
weil wir zu spaet zur <>oma amen
verpassten wir das …
u 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
#include
char s1[100],s2[100],c1[100],c2[100],l1[100],l2[100];int main(){
int cad,n,i,j,k,m,t,a,b,e,f; scanf("%d",&cad); getchar(); while(cad--) {
memset(s1,0,sizeof(s1)); memset(s2,0,sizeof(s2)); memset(c1,0,sizeof(c1)); memset(c2,0,sizeof(c2)); memset(l1,0,sizeof(l1)); memset(l2,0,sizeof(l2)); fgets(s1,sizeof(s1),stdin); fgets(s2,sizeof(s2),stdin); n=strlen(s1); m=strlen(s2); for(j=0;j
') continue; printf("%c",s1[j]); } for(i=n-1;i>=0;i--) {
if(s1[i]=='>') a=i; if(s1[i]=='<') {
b=i; break; } } for(i=0;i
') {
f=i; break; } } for(i=0;i

转载地址:http://hgxzi.baihongyu.com/

你可能感兴趣的文章
模态对话框的销毁过程与非模态对话的几种销毁方法
查看>>
C++实现http下载 && 24点计算编码风格
查看>>
memcached了解使用和常用命令详解
查看>>
GDB调试各功能总结
查看>>
"undefined reference to" 多种可能出现的问题解决方法
查看>>
类结构定义
查看>>
Windows下关于多线程类 CSemaphore,CMutex,CCriticalSection,CEvent,信号量CSemaphore的使用介绍
查看>>
图像处理基本算法(汇总)以及实现
查看>>
C++编程获取本机网卡信息 本机IP 包括Windows和Linux
查看>>
23种设计模式详解及C++实现
查看>>
C++连接CTP接口实现简单量化交易
查看>>
服务端使用c++实现websocket协议解析及通信
查看>>
C# string.Format使用说明
查看>>
Linux下安装Mysql数据库开发环境
查看>>
Linux用户及用户组添加和删除操作
查看>>
通用 Makefile 的编写方法以及多目录 makefile 写法
查看>>
C++的4种智能指针剖析使用
查看>>
RPC框架实现之容灾策略
查看>>
Docker私库
查看>>
hdu——1106排序(重定向)
查看>>