“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. ...
chinese-poetry 最全中文诗歌古典文集数据库.zip
chinese-poetry.zip,最全中华古诗词数据库, 唐宋两朝近一万四千古诗人, 接近5.5万首唐诗加26万宋诗. 两宋时期1564位词人,21050首词。
人工智能学习资料-poetry(RNN诗人) 程序RNN 人工智能学习资料-poetry(RNN诗人) 程序RNN 人工智能学习资料-poetry(RNN诗人) 程序RNN
docker-python-poetry 一个预先安装了诗歌的基于Debian的python docker容器。 该图像是根据官方的python slim-buster图像构建的。 在上查看图像 根据要查找的python版本,有一些不同的标签。 标签结构是POETRY ...
最全的中华古典文集数据库,包含 5.5 万首唐诗、26 万首宋诗、2.1 万首宋词和其他古典文集。诗人包括唐宋两朝近 1.4 万古诗人,和两宋时期 1.5 千古词人。数据来源于互联网。 为什么要做这个仓库?...
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周创建
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|...
资源来自pypi官网。 资源全名:my-poetry-package-0.1.0.tar.gz
python库。 资源全名:takano32-poetry-0.1.0.tar.gz
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 注意: ...
poetry-tox-pre-commit-ci-cd-instance用法去做高级用法概述去做步骤0说明import cookiecutter_cruft_poetry_tox_pre_commit_ci_cd_instance# TODO发展 :memo: 笔记为了方便起见,下面的许多过程都被抽象并封装在...
人工智能-项目实践-yolov-YOLOv3的最低PyTorch实现 安装 从源代码安装 对于正常的训练和评估,我们... 如果您想在不打开 poetry-shell 的情况下在任何地方使用命令,还可以查看其他安装方法。poetry shellpoetry run
可以帮助您声明,管理和安装Python项目的依赖关系,确保您在任何地方都拥有合适的堆栈。
npm install classify-poetry用法诗歌分类 import { classifyPoetry } from "classify-poetry" ;const types = classifyPoetry ( "detect a haiku \n pleased to do, says algorithm \n thanks algorithm") ;...