Problem I
Automatic Poetry
Input:standard input
Output:standard output
Time Limit:2 seconds
Memory Limit:32 MB
“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
TUD Programming Contest
【题意】:
输入:
输入N组测试用例,每组输入两个字符串。
第一个字符串格式:s1<s2>s3<s4>s5
s1,s2,s3,s3,s4,s5都可以为空或者不存在或者全是小写字符
第二个字符串格式:s ....
输出:
每组测试用例输出两个字符串。
第一个字符串格式:s1s2s3s4s5
第二个字符串格式:ss4s3s2s5
【代码】:
-
-
-
-
-
-
-
-
-
-
#include<stdio.h>
-
#include<string.h>
-
#defineN110
-
intmain(){
-
inti,j,Case,lena,lenb;
-
chara[N],b[N],s[N],s1[N],s2[N],s3[N],s4[N],s5[N];
-
-
while(scanf("%d\n",&Case)!=EOF){
-
while(Case--){
-
gets(a);
-
gets(b);
-
lena=strlen(a);
-
-
for(j=0,i=0;a[i]!='<';i++,j++){
-
s1[j]=a[i];
-
}
-
s1[j]='\0';
-
-
-
for(i=i+1,j=0;a[i]!='>';i++,j++){
-
s2[j]=a[i];
-
}
-
s2[j]='\0';
-
-
-
for(i=i+1,j=0;a[i]!='<';i++,j++){
-
s3[j]=a[i];
-
}
-
s3[j]='\0';
-
-
-
for(i=i+1,j=0;a[i]!='>';i++,j++){
-
s4[j]=a[i];
-
}
-
s4[j]='\0';
-
-
-
for(i=i+1,j=0;i<lena;i++,j++){
-
s5[j]=a[i];
-
}
-
s5[j]='\0';
-
-
-
for(i=0,j=0;b[i]!='.';i++,j++){
-
s[j]=b[i];
-
}
-
s[j]='\0';
-
-
-
printf("%s%s%s%s%s\n",s1,s2,s3,s4,s5);
-
printf("%s%s%s%s%s\n",s,s4,s3,s2,s5);
-
}
-
}
-
return0;
-
}
-
-
-
#include<iostream>
-
#include<string>
-
usingnamespacestd;
-
-
#defineMAXN102
-
stringa1,a2;
-
-
voidsolve()
-
{
-
intp1=a1.find('<',0);
-
intp2=a1.find('>',0);
-
intp3=a1.find('<',p2+1);
-
intp4=a1.find('>',p2+1);
-
strings1=a1.substr(0,p1);
-
strings2=a1.substr(p1+1,p2-p1-1);
-
strings3=a1.substr(p2+1,p3-p2-1);
-
strings4=a1.substr(p3+1,p4-p3-1);
-
strings5=a1.substr(p4+1);
-
cout<<s1<<s2<<s3<<s4<<s5<<endl;
-
a2.replace(a2.length()-3,3,s4+s3+s2+s5);
-
cout<<a2<<endl;
-
}
-
-
intmain()
-
{
-
intt;cin>>t;
-
cin.get();
-
while(t--)
-
{
-
getline(cin,a1);
-
getline(cin,a2);
-
solve();
-
}
-
}
-
分享到:
相关推荐
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 ... 因此,如果您想使用Poetry和Python 3.8,则可以使用以下标记之一,具体取决于您希望对诗歌版本1-3.8或1.1-3.8或1.1.4-3.8 请注意,当前只有与最新版本诗歌相对应的标签会更新其基本图片。
最全的中华古典文集数据库,包含 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: 笔记为了方便起见,下面的许多过程都被抽象并封装在...
可以帮助您声明,管理和安装Python项目的依赖关系,确保您在任何地方都拥有合适的堆栈。
为了启用将poetry-core用作构建后端,必须在项目的pyproject.toml文件中包含以下片段。 [ build-system ] requires = [ " poetry-core " ] build-backend = " poetry.core.masonry.api " 一旦存在,像pip这样的...
用法如果您需要的只是默认诗歌,只需将其添加到您的工作流程中即可:- name : Install Poetry uses : snok/install-poetry@v1.1.4 如果要设置诗歌配置设置或安装特定版本,则可以指定输入- name : Install and ...