“Oh God”, Lara Croft exclaims, “it’sone 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 Kindhaltseinen Schnabel nur,
wennes 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
wherethe siare 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 willweat most 100 characters long.
Output
For each pair of Schuttelreim lines l1and l2you are to output two lines c1and c2in the following way: c1is the same as l1only that the bracket marks “<” and “>” are removed. Line c2is the same asl2,except that instead of the three dots the string s4s3s2s5should appear.
Sample Input
3
einkind haelt seinen <schn>abel <n>ur
wennes haengt an der ...
weilwir zu spaet zur <>oma <k>amen
verpasstenwir das ...
<d>u <b>ist
...
Sample Output
einkind haelt seinen schnabel nur
wennes haengt an der nabel schnur
weilwir zu spaet zur oma kamen
verpasstenwir das koma amen
dubist
budist
//#define RUN #ifdef RUN #include <stdio.h> #include <stdlib.h> #include <string.h> #include <assert.h> #include <string> #include <iostream> #include <sstream> #include <map> #include <set> #include <vector> #include <list> #include <cctype> #include <algorithm> #include <utility> #include <math.h> using namespace std; #define MAXN 105 //char l1[MAXN]; //char l2[MAXN]; string l1; string l2; void play(){ bool leftB1 = false; bool rightB1 = false; bool leftB2 = false; bool rightB2 = false; string s2, s3, s4, s5; s2.clear(); s3.clear(); s4.clear(); s5.clear(); for(int i=0; i<l1.length(); i++){ //第一次找到< if(!leftB1 && !rightB1 && l1[i]=='<' && !leftB2 && !rightB2){ leftB1 = true; continue; } //第一次找到> if(leftB1 && !rightB1 && l1[i]=='>' && !leftB2 && !rightB2){ rightB1 = true; continue; } //找到第一个<>中间的字符 if(leftB1 && !rightB1 && !leftB2 && !rightB2){ s2 += l1[i]; continue; } //第二次找到< if(leftB1 && rightB1 && !leftB2 && !rightB2 && l1[i]=='<'){ leftB2 = true; continue; } //找到第一个<>到第二个<>之间的字符 if(leftB1 && rightB1 && !leftB2 && !rightB2){ s3 += l1[i]; continue; } //第二次找到> if(leftB1 && rightB1 && leftB2 && !rightB2 && l1[i]=='>'){ rightB2 = true; continue; } //找到第二个<>中间的字符 if(leftB1 && rightB1 && leftB2 && !rightB2){ s4 += l1[i]; continue; } //找到第二个<>后面的字符 if(leftB1 && rightB1 && leftB2 && rightB2){ s5 += l1[i]; continue; } } int l1start = l1.find('<'); string s1 = l1.substr(0, l1start); //cout << "s2:" << s2 << endl; //cout << "s3:" << s3 << endl; //cout << "s4:" << s4 << endl; //cout << "s5:" << s5 << endl; cout << (s1+s2+s3+s4+s5) << endl; string combine = s4+s3+s2+s5; int l2start = l2.find("..."); cout << l2.replace(l2start,3,combine) << endl; } int main(){ #ifndef ONLINE_JUDGE freopen("10361.in", "r", stdin); freopen("10361.out", "w", stdout); #endif int n; scanf("%d", &n); getchar(); for(int i=0; i<n; i++){ l1.clear(); l2.clear(); //memset(l1, '\0', sizeof(l1)); //memset(l2, '\0', sizeof(l2)); //fgets(l1, MAXN, stdin); //fgets(l2, MAXN, stdin); getline(cin, l1); getline(cin, l2); //cout << l1 << endl; //cout << l2 << endl; play(); } } #endif
相关推荐
Automatic-creation-of-Tibetan-poetry-and-Tang-poetry Introduction Automatic creation of Tibetan poetry and Tang poetry based on LSTM in tensorflow. Data The training data set is 34,646 Tang poems. ...
最全的中华古典文集数据库,包含 5.5 万首唐诗、26 万首宋诗、2.1 万首宋词和其他古典文集。诗人包括唐宋两朝近 1.4 万古诗人,和两宋时期 1.5 千古词人。数据来源于互联网。 为什么要做这个仓库?...
这个压缩包文件的核心是`chinese-poetry-master`目录,里面详细整理了中国古代的诗词文献,是研究中国古典文学、诗歌艺术以及进行自然语言处理(NLP)相关工作的重要资料库。 一、数据集概述 该数据集以“chinese-...
docker-python-poetry 一个预先安装了诗歌的基于Debian的python docker容器。 该图像是根据官方的python slim-buster图像构建的。 在上查看图像 根据要查找的python版本,有一些不同的标签。 标签结构是POETRY ...
诗词集_chinese-poetry_的数据导入工具_chinese-poetry-Mysql-Elastic
压缩包中的"chinese-poetry-master"可能是一个包含各种文件和结构的目录,用于存储这些诗词的数据。这可能包括文本文件,每个文件代表一位诗人或一个时期的诗词集合;或者是一个数据库文件,结构化地存储了诗人的...
例如,`poetry-dynamic-versioning`插件可以根据git历史自动更新版本号,`poetry-upgrade`则能帮助一键升级所有依赖。 总的来说,Python-Poetry通过其简洁的命令行接口和全面的依赖管理策略,简化了Python项目的...
《PyPI官网下载:my-poetry-package-0.1.0.tar.gz——深入解析Python库的发布与使用》 PyPI(Python Package Index),是Python社区最重要的资源库,它为全球Python开发者提供了一个集中分享和下载Python软件包的...
《Python库takano32-poetry-0.1.0深度解析》 在Python的世界里,库扮演着至关重要的角色,它们为开发者提供了丰富的功能,简化了代码编写,提高了开发效率。今天我们要探讨的是名为“takano32-poetry-0.1.0”的...
在本资源包“人工智能学习资料-poetry(RNN诗人)”中,主要涵盖了人工智能领域的一个具体应用——使用循环神经网络(Recurrent Neural Network,RNN)进行诗歌创作。循环神经网络是深度学习的一种模型,特别适合...
chinese-poetry-to-mysql-tool简介把 仓库里的json数据转换成 sql 文件的工具环境php 5.6 +git使用1、下载本工具git clone https://github.com/woodylan/chinese-poetry-to-mysql-tool.git2、在本工具目录下,下载 ...
项目1-GitHub Poetry 在第3周创建
"chinese-poetry-learning-master"就是这样一个专为中文古诗词学习设计的工具,旨在帮助教师和学生更好地理解和创作古诗词。这个项目内置了丰富的中文古诗词数据,结合现代计算机技术,提供了自主生成古诗词的功能,...
深度学习大作业Python基于LSTM自动写诗源代码+详细文档+PPT,数据集采用chinese-poetry,含有代码注释,新手也可看懂,个人手打98分项目,导师非常认可的高分项目,期末大作业和课程设计高分必看,下载下来,简单...
SQLite格式的 $ sqlite3 poetry.sqliteSQLite version 3.19.3 2017-06-27 16:48:08Enter ".help" for usage hints.sqlite> .tablespoetrysqlite> PRAGMA table_info(poetry);0|title|TEXT|0||01|author|TEXT|0||02|...
Github Action安装诗歌不会执行此操作。 使用 INSTEAD!...poetry-action@v1.3 with : version : 1.0.0a1 或使用预览版本(与version选项不兼容) - uses : dschep/install-poetry-action@v1.3 with
Ajax-poetry-web.zip,一、网络项目承办单位,ajax代表异步javascript和xml。它是多种web技术的集合,包括html、css、json、xml和javascript。它用于创建动态网页,其中网页的小部分在不重新加载网页的情况下更改。
资源分类:Python库 所属语言:Python 资源全名:dh-poetry-0.2.0.tar.gz 资源来源:官方 安装方法:https://lanzao.blog.csdn.net/article/details/101784059
语言:English (United States) 萨德诗歌是乌尔都语诗歌,Shayari和乌尔都语Ghazals的最新作品集,在巴基斯坦和世界各地都非常有名。 该应用程序经过独特设计,可提供全新的诗歌。 在这里,您可以找到最可爱,浪漫,...
目录安装通过 (推荐): cruft create https://github.com/TeoZosa/cookiecutter-cruft-poetry-tox-pre-commit-ci-cd 通过 : cookiecutter gh:TeoZosa/cookiecutter-cruft-poetry-tox-pre-commit-ci-cd 注意: ...