Automatic Poetry
Time Limit: 1000MS Memory Limit: 30000K
Total Submissions: 2373 Accepted: 1176

Description

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

Source

TUD Programming Contest 2001, Darmstadt, Germany

问题链接:POJ1917 UVA10361 Automatic Poetry
问题简述:(略)
问题分析
    这个是一个文本处理题,用C++的string类有关的函数(方法)就可以实现了。关键是要了解那些函数及其参数的使用。
程序说明:(略)
参考链接:(略)
题记:(略)

AC的C++语言程序如下:

/* POJ1917 UVA10361 Automatic Poetry */#include <iostream>
#include <string>using namespace std;int main()
{int n;string i1, i2;cin >> n;getline(cin, i1);while(n--) {int pos1, pos2, pos3, pos4, pos5;getline(cin, i1);getline(cin, i2);pos1 = i1.find('<');pos2 = i1.find('>', pos1);pos3 = i1.find('<', pos2);pos4 = i1.find('>', pos3);pos5 = i2.find('.');string s1 = i1.substr(0, pos1);string s2 = i1.substr(pos1+ 1, pos2 - pos1 - 1);string s3 = i1.substr(pos2 + 1, pos3 - pos2 - 1);string s4 = i1.substr(pos3 + 1, pos4 - pos3 - 1);string s5 = i1.substr(pos4 + 1);string s6 = i2.substr(0, pos5);cout << s1 << s2 << s3 << s4 << s5 << endl;cout << s6 << s4 << s3 << s2 << s5 << endl;}return 0;
}

POJ1917 UVA10361 Automatic Poetry【文本】相关推荐

  1. TYUT-A专题题解(一)

    TYUT-A专题题解(一) 01A Ad Hoc UVA353 LA5247 Pesky Palindromes[回文] - 海岛Blog - CSDN博客 UVA947 Master Mind He ...

  2. AOAPC I: Beginning Algorithm Contests 题解

    AOAPC I: Beginning Algorithm Contests 题解 AOAPC I: Beginning Algorithm Contests (Rujia Liu) - Virtual ...

  3. PaperWeekly 第二十三期 --- 机器写诗

    引言 什么是艺术? 机器的作品能否叫艺术? 机器能否取代艺术家? 这些问题,相信不同的人,会有不同的答案.很多人认为机器生成的作品只是简单的模仿人类,没有创造性可言,但是人类艺术家,不也是从模仿和学习 ...

  4. NLP 2020顶会论文汇总,今天你读了吗?

    疯狂泛读中 找到自己感兴趣的方向了 应该不进行更新了 大佬整理的顶会论文 目录 NLP经典基础paper: 图像描述基础paper: NIPS 2020: ACL 2020: 最佳论文(1个) 荣誉提 ...

  5. ACL2020论文整理

    ACL2020论文整理目录 ACL2020论文整理(Main Conference) ACL2020接受文章列表 Best Paper Honorable Mention Papers – Main ...

  6. ACL2020-最新录用论文列表分享

    ACL会议(Annual Meeting of the Association for Computational Linguistics)是自然语言处理与计算语言学领域最高级别的学术会议,由计算语言 ...

  7. POJ前面的题目算法思路【转】

    1000 A+B Problem 送分题 49% 2005-5-7 1001 Exponentiation 高精度 85% 2005-5-7 1002 487-3279 n/a 90% 2005-5- ...

  8. 提取了下刘汝佳推荐的题号...

    今天闲来没事上uva oj提取了下刘汝佳推荐的acm题号,原始数据如下: Volume 0. Getting Started    10055 - Hashmat the Brave Warrior ...

  9. Qt + halcon混合编程 相机标定

    1.项目环境:Qt 5.14       halcon18      win10/ubuntu20 2.运行效果图: 3.创建一个Qt项目,修改项目文件(Qt的跨平台是指代码跨平台,在windows和 ...

最新文章

  1. 解决push的时候有时候会卡一下的问题
  2. IIS Express总结
  3. 行式填报表轻松搞定流水号
  4. 如何做一个新产品的第一个版本:关于MVP和上线时间的权衡
  5. 从需求到交付——论敏捷过程中的需求管理
  6. ENVI学习总结(二)——基于自带定位信息的几何校正
  7. Camshift算法(1)
  8. ansys命令流——网格划分基础操作
  9. spark入门demo
  10. gif一键抠图 在线_免费在线抠图软件
  11. 51单片机,485,测试03/05/06
  12. python毕业设计 基于django框架企业公司网站系统毕业设计设计与实现
  13. (六)分布式系统认证方案
  14. HTML行内元素、块级元素和行内块元素
  15. Android 锁定屏幕方向 横向或竖向 支持Android10
  16. 针对严峻的网络安全环境,公司就当如何应对?
  17. GC垃圾回收—详细总结
  18. 计算机录入的课程标准,《文字录入》课程标准.doc
  19. hadoop3 Yarn容量(Capacity Scheduler)调度器和公平(Fair Scheduler)调度器配置
  20. 现实世界的映射与超越:电子游戏的叙事研究

热门文章

  1. 使用GDAL将下载的Google卫星图像转为带坐标的tif
  2. 汽车编程都是用matlab,MATLAB编程与汽车仿真应用
  3. Android中Bitmap缓存池
  4. 游戏接腾讯平台的一些锁事
  5. c#制作的简单的画图板
  6. mysql jdbc配置重连_Spring Boot 配置MySQL数据库重连的操作方法
  7. 每天Leetcode 刷题 初级算法篇-缺失数字
  8. python 括号 垃圾_Python 为什么抛弃累赘的花括号,使用缩进来划分代码块?
  9. explain如何查看mysql_MySql中如何使用 explain 查询 SQL 的执行计划
  10. php shell ddos,用shell解决ddos攻击实例