Automatic Poetry

2024-08-22 14:38
文章标签 automatic poetry

本文主要是介绍Automatic Poetry,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

Description

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

 

/*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

 

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 <schn>abel <n>ur

wenn es haengt an der ...

weil wir zu spaet zur <>oma <k>amen

verpassten wir das ...

<d>u <b>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 <stdio.h>
char a[2000] = {'\0'};
char s1[1000] = {'\0'};
char s2[1000] = {'\0'};
char s3[1000] = {'\0'};
char s4[1000] = {'\0'};
char s5[1000] = {'\0'};
char s[1000] = {'\0'};
void pri(void)
{
printf ("%s%s%s%s%s\n",s1,s2,s3,s4,s5);
printf ("%s%s%s%s%s\n",s,s4,s3,s2,s5);
}
int main()
{
int n = 0,i = 0;
char *p1 = NULL,*p2 = NULL;
scanf ("%d%*c",&n);
for (i = 0;i < n;i++)
{
gets (a);
p1 = a;
p2 = s1;
while (*p1 != '<')
{
*p2 = *p1;
p1++;
p2++;
}
*p2 = '\0';
p2 = s2;
p1++;
while (*p1 != '>')
{
*p2 = *p1;
p1++;
p2++;
}
*p2 = '\0';
p2 = s3;
p1++;
while (*p1 != '<')
{
*p2 = *p1;
p1++;
p2++;
}
*p2 = '\0';
p2 = s4;
p1++;
while (*p1 != '>')
{
*p2 = *p1;
p1++;
p2++;
}
*p2 = '\0';
p2 = s5;
p1++;
while (*p1 != '\0')
{
*p2 = *p1;
p1++;
p2++;
}
*p2 = '\0';
gets (s);
p1 = s;
while (*p1 != '.')
p1++;
*p1 = '\0';
pri();
}
return 0;
}

这篇关于Automatic Poetry的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/1096557

相关文章

UVa10361_Automatic Poetry(小白书字符串专题)

Automatic Poetry Input: standard input Output: standard output Time Limit: 2 seconds Memory Limit: 32 MB   “Oh God”, Lara Croft exclaims, “it’s one of these dumb riddles again!”   In Tomb R

3D Deeply Supervised Network for Automatic Liver Segmentation from CT Volumes

下面博主详细翻译了该篇论文,可以当做详尽的参考,并认真学习。 【参考】论文笔记:3D Deeply Supervised Network for Automatic Liver Segmentation from CT 数据集: MICCAI-SLiver07[1] 数据预处理: 作者没有讲数据预处理的过程。 CRF 轮廓精细修正: 参考上述博主博客。 参考文献: [1]Heimann,

macOS搭建Python3.11+Django4.2.15的平台框架使用Poetry管理

最近想使用Python开发,使用Django框架搭建平台,之前没有使用过Python,所以记录下整个过程: 1、Python版本的选择,直接去官网【Download Python | Python.org】看最新稳定版是哪个版本,选择安装,可以看到目前是3.11.9版本,安装它。 由于Python的版本过多,可以安装一个版本管理工具,这里我选择pyenv,pyenv 是一个简单的Pytho

Automatic Educational Question Generation with Difficulty Level Controls

文章目录 题目摘要简介相关工作问题表述实验用户研究结论 题目 具有难度级别控制的自动教育问题生成 论文地址:https://link.springer.com/chapter/10.1007/978-3-031-36272-9_39 摘要     我们考虑自动生成各种难度的数学应用题 (MWP),以满足教师在相应教育阶段教学和测试学生的需求。现有方法无法生成高质

论文研读 Automatic TCP Buffer Tuning

由于“动态右尺寸”(DRS)的方法关于其自动调优方法的介绍并不清楚,改读了论文"Automatic TCP Buffer Tuning"。其中调节接收缓存大小的想法就是,“动态调整接收套接字缓冲区的一个想法是在缓冲区大部分为空时增加缓冲区大小,因为缺少排队等待应用程序传输的数据表明数据速率低,这可能是接收窗口限制连接的结果。在恢复期间达到峰值使用量(由丢失的数据包指示),因此,如果缓冲区大小远大于

Automatic Preferred Max Layout Width is not available on

在Xcode6下开发时,使用autolayout的xib出现警告:Automatic Preferred Max Layout Width is not available on iOS versions prior to 8.0 原因:xcode6下默认开启自动设置UILabel的 preferredMaxLayoutWidth  的属性,而自动的特性只支持iOS8,故导致这个警

uva 10361 Automatic Poetry(字符串处理)

Automatic Poetry Input: standard input Output: standard output Time Limit: 2 seconds Memory Limit: 32 MB   “Oh God”, Lara Croft exclaims, “it’s one of these dumb riddles again!”   In Tomb

论文阅读:《BLEU: a Method for Automatic Evaluation of Machine Translation》

https://blog.csdn.net/qq_21190081/article/details/53115580 论文地址:http://xueshu.baidu.com/s?wd=paperuri%3A%2888a98dec5bea94cca9f474db30c36319%29&filter=sc_long_sign&tn=SE_xueshusource_2kduw22v&sc_vurl=

《python》安装poetry库-FileNotFoundError: [WinError 2] 系统找不到指定的文件。-问题解决以及安装

问题描述: 使用指令: curl -sSL https://install.python-poetry.org | python3 - 安装 poetry的时候出现这个问题:  具体报错: Retrieving Poetry metadata# Welcome to Poetry!This will download and install the latest version of

Poetry Camera照相机将照片转换成诗歌并打印出来;吴恩达新课程深入了解Mistral;科学研究AI小助手data-to-paper

✨ 1: Poetry Camera 将拍摄的照片转换成诗歌并打印出来 Poetry Camera——一个能够把它所见之物转化成诗歌并打印出来的相机。你在一个美丽的公园,或者是一个充满故事的老街道。只要用Poetry Camera拍下这一刻,它就能立刻给你一首关于这个场景的诗。 Poetry Camera的核心是一个Raspberry Pi Zero 2 W,这是一个小巧但功能强大的