UVA10361 - Automatic Poetry(自动作诗机)

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 <string.h>
#define MAXN 110
void getss(char s[]);
int main()
{
freopen("data.in","r",stdin);
int n;
char s1[MAXN],s2[MAXN],s3[MAXN],s4[MAXN],s5[MAXN],c,line[MAXN];
scanf("%d",&n);
c = getchar();
while(n--)
{
getss(s1);
getss(s2);
getss(s3);
getss(s4);
getss(s5);
gets(line);
line[strlen(line) - ] = '\0';
printf("%s%s%s%s%s\n",s1,s2,s3,s4,s5);
printf("%s%s%s%s%s\n",line,s4,s3,s2,s5);
}
return ;
} void getss(char s[])
{
int i;
for(i=; i<MAXN; i++)
{
if((s[i] = getchar()) == '<' || s[i] == '>' || s[i] == '\n'){
s[i] = '\0';
break;
}
}
}

我自己的解法,同大家分享交流:

 #include "stdio.h"
#include "string.h"
char s[],m[],p[][];
int main(){
int n,i,j,q,k;
scanf("%d ",&n);
for(i=;i<n;i++)
{
q=k=;
fgets(s,sizeof(s),stdin);
fgets(m,sizeof(m),stdin);
for(j=;j<strlen(s);j++)
{
p[q][k]=s[j];
k++;
if(s[j]=='<'||s[j]=='>'){p[q][k-]='\0';k=;q++;continue;}
printf("%c",s[j]);
}
p[q][k]='\0';
m[strlen(m) - ]='\0';
printf("%s%s%s%s%s",m,p[],p[],p[],p[]);
}
return ;
}

UVA10361 -自动作诗机的更多相关文章

  1. 【机器学习】无监督学习Autoencoder和VAE

    众所周知,机器学习的训练数据之所以非常昂贵,是因为需要大量人工标注数据. autoencoder可以输入数据和输出数据维度相同,这样测试数据匹配时和训练数据的输出端直接匹配,从而实现无监督训练的效果. ...

  2. 学习笔记(25)- NLP的几个概念

    NLP的几个概念 从技术研究的角度,简单介绍自然语言处理的几个概念 1. 对抗学习 主要指对抗生成网络. 2个主要构成:判别器.生成器 判别模型尽可能提取特征正确率增加的模型,生成模型尽可能" ...

  3. PDA手持机 移动开单进销存系统 现场出打印凭据和扫码 新的亮点

    传统车销模式弊端:1.手写开单,效率低,动作慢2.现场手写开单明细不能打印,产品明细不规范3.电脑办公人员及车销人员对车上的库存情况掌握不清楚,销售人员对每种产品销售价格不清楚4.老板对员工工作的管控 ...

  4. Python之路Day13--堡垒机

    一.前景介绍 到目前为止,很多公司对堡垒机依然不太感冒,其实是没有充分认识到堡垒机在IT管理中的重要作用的,很多人觉得,堡垒机就是跳板机,其实这个认识是不全面的,跳板功能只是堡垒机所具备的功能属性中的 ...

  5. JSP基础总结(运行机制、脚本元素、指令元素、动作元素)

    JSP的运行机制: 1.转译阶段:JSP页面转换成Servlet类: 2.请求阶段:Servlet类执行,将相应结果发送至客户端. 流程解释: 1.用户访问某个JSP页面 2.服务器找到相应的JSP页 ...

  6. XE7 & IOS开发之开发账号(2):发布证书、发布授权profile的申请使用,附Ad hoc真机调试、生成ipa文件演示(XCode所有版本通用,有图有真相)

    网上能找到的关于Delphi XE系列的移动开发的相关文章甚少,本文尽量以详细的图文内容.傻瓜式的表达来告诉你想要的答案. 原创作品,请尊重作者劳动成果,转载请注明出处!!! 注意,以下讨论都是以&q ...

  7. 2016古装动作喜剧《笨贼别跑》HD720P.国语中字

    导演: 雷金克编剧: 郭卫鹏 / 李诗怡 / 马强主演: 彭波 / 李添诺 / 董向荣 / 韩丰 / 董怡君类型: 喜剧 / 动作 / 古装制片国家/地区: 中国大陆语言: 汉语普通话上映日期: 20 ...

  8. [转发]dsdt解决睡眠唤醒死机

    登录 注册 首页 热门话题 最新发布   简单模式 详细模式 dsdt解决睡眠唤醒死机 Leave a reply 首先,感谢x5115x提供了一个相对比较完整的THINKPAD T410在MAC下的 ...

  9. MSP430G2333下位机乘法运算需要注意的一个问题

    背景: 最近负责为主板管理电源的电源管理模块编写软体,使用的MCU为MSP430G2333.功能上很简单,即通过板子上的硬件拨码设定,或者通过IIC与主板通信,由主板的BIOS决定开机及关机的延时供电 ...

随机推荐

  1. jquery的学习

    可选的 speed 参数规定隐藏/显示的速度,可以取以下值:"slow"."fast" 或毫秒.可选的 callback 参数是动画 100% 完成后所执行的函 ...

  2. Load Balancing 折半枚举大法好啊

    Load Balancing 给出每个学生的学分.   将学生按学分分成四组,使得sigma (sumi-n/4)最小.         算法:   折半枚举 #include <iostrea ...

  3. 【鬼脸原创】github搭建动态网站

    a{ color:blue; font-weight:bold; } #cnblogs_post_body ol li { list-style-type: cjk-ideographic; } p[ ...

  4. VA中修改函数注释

    在VA中修改对应的函数和文件注释,可以使用VA自动产生函数和文件头注释 //************************************************************** ...

  5. 【Mood-18】github 使用指南

    windows下使用教程: http://www.cnblogs.com/dongdong230/p/4211221.html repository not found error问题解决(需确定gi ...

  6. 【Shell脚本学习11】Shell注释

    以“#”开头的行就是注释,会被解释器忽略. sh里没有多行注释,只能每一行加一个#号.只能像这样: #-------------------------------------------- # 这是 ...

  7. Android使用MVP时应该注意的问题

    生命周期:因为Presenter是View创建的,我们需要确保完全地理解View的生命周期,特别是因为它将最有可能去处理状态更新和异步数据.举个例子,每一个Presenter应该在View destr ...

  8. Mindjet MindManager 2016/2017 折腾记录

    https://community.mindjet.com/mindjet/topics/ensure-2017-64-bit-version-installation Mindmanager sho ...

  9. Linux文件系统的barrier:启用还是禁用

    大多数当前流行的Linux文件系统,包括EXT3和EXT4,都将文件系统barrier作为一个增强的安全特性.它保护数据不被写入日记.但 是,在许多情况下,我们并不清楚这些barrier是否有用.本文 ...

  10. [wordpress] determine_current_user 在get_current_user_id() 或者 wp_get_current_user()会调用

    在看了Cookie Authentication In A AngularJS WordPress Theme之后,清楚了当Wordpress在中使用get_current_user_id() 或者w ...