UVA10361 -自动作诗机
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 -自动作诗机的更多相关文章
- 【机器学习】无监督学习Autoencoder和VAE
众所周知,机器学习的训练数据之所以非常昂贵,是因为需要大量人工标注数据. autoencoder可以输入数据和输出数据维度相同,这样测试数据匹配时和训练数据的输出端直接匹配,从而实现无监督训练的效果. ...
- 学习笔记(25)- NLP的几个概念
NLP的几个概念 从技术研究的角度,简单介绍自然语言处理的几个概念 1. 对抗学习 主要指对抗生成网络. 2个主要构成:判别器.生成器 判别模型尽可能提取特征正确率增加的模型,生成模型尽可能" ...
- PDA手持机 移动开单进销存系统 现场出打印凭据和扫码 新的亮点
传统车销模式弊端:1.手写开单,效率低,动作慢2.现场手写开单明细不能打印,产品明细不规范3.电脑办公人员及车销人员对车上的库存情况掌握不清楚,销售人员对每种产品销售价格不清楚4.老板对员工工作的管控 ...
- Python之路Day13--堡垒机
一.前景介绍 到目前为止,很多公司对堡垒机依然不太感冒,其实是没有充分认识到堡垒机在IT管理中的重要作用的,很多人觉得,堡垒机就是跳板机,其实这个认识是不全面的,跳板功能只是堡垒机所具备的功能属性中的 ...
- JSP基础总结(运行机制、脚本元素、指令元素、动作元素)
JSP的运行机制: 1.转译阶段:JSP页面转换成Servlet类: 2.请求阶段:Servlet类执行,将相应结果发送至客户端. 流程解释: 1.用户访问某个JSP页面 2.服务器找到相应的JSP页 ...
- XE7 & IOS开发之开发账号(2):发布证书、发布授权profile的申请使用,附Ad hoc真机调试、生成ipa文件演示(XCode所有版本通用,有图有真相)
网上能找到的关于Delphi XE系列的移动开发的相关文章甚少,本文尽量以详细的图文内容.傻瓜式的表达来告诉你想要的答案. 原创作品,请尊重作者劳动成果,转载请注明出处!!! 注意,以下讨论都是以&q ...
- 2016古装动作喜剧《笨贼别跑》HD720P.国语中字
导演: 雷金克编剧: 郭卫鹏 / 李诗怡 / 马强主演: 彭波 / 李添诺 / 董向荣 / 韩丰 / 董怡君类型: 喜剧 / 动作 / 古装制片国家/地区: 中国大陆语言: 汉语普通话上映日期: 20 ...
- [转发]dsdt解决睡眠唤醒死机
登录 注册 首页 热门话题 最新发布 简单模式 详细模式 dsdt解决睡眠唤醒死机 Leave a reply 首先,感谢x5115x提供了一个相对比较完整的THINKPAD T410在MAC下的 ...
- MSP430G2333下位机乘法运算需要注意的一个问题
背景: 最近负责为主板管理电源的电源管理模块编写软体,使用的MCU为MSP430G2333.功能上很简单,即通过板子上的硬件拨码设定,或者通过IIC与主板通信,由主板的BIOS决定开机及关机的延时供电 ...
随机推荐
- Masonry 布局 cell 高度适应的一种方案(实现类似朋友圈简单布局)
来源:伯乐在线 - 夏天然后 链接:http://ios.jobbole.com/89298/ 点击 → 申请加入伯乐在线专栏作者 前言: 我模仿的是微博的布局所以也就没有 评论动态刷新cell. 1 ...
- C#中的多态现象
面向对象的特征封装.继承和多态.Polymorphism(多态性)来源于希腊单词,指“多种形态”.多态性的一个重要特征是方法的调用是在运行时确定而不是编译时.在.NET中用于实现多态性的关键词有vir ...
- jquery . fancybox()
1.父页面 function chooseTopic(btn) {//选择议题 $.fancybox({ type : 'iframe', href : '', fitToView : false, ...
- 关于变量在for循环内外定义的思考
在c#或java里面,我们通常会这样写for循环: ;i<;i++) { Console.WriteLine(i); } 前一阵子,我突发奇想,如果按照下面这样写,会不会比上面的运行效率高一些: ...
- 批量更新memcached缓存
假如系统里有3类数据company,user,product 利用维护版本号version的方式达到批量更新缓存的效果 memcache.Add("company",cversio ...
- Android 高级UI设计笔记15:HorizontalScrollView之 实现画廊式图片浏览器
1. HorizontalScrollView 本来,画廊式的图片浏览器,使用Android中的Gallery就能轻松完成,但是Google说Gallery每次切换图片时都要新建视图,造成太多的资源浪 ...
- 【阿里云产品公测】简单日志服务SLS使用评测 + 教程
[阿里云产品公测]简单日志服务SLS使用评测 + 教程 评测介绍 被测产品: 简单日志服务SLS 评测环境: 阿里云基础ECS x2(1核, 512M, 1M) 操作系统: CentOS 6.5 x6 ...
- Oracle 11g R2 for Win7旗舰版(64位)的安装步骤
1.下载Oracle 11g R2 for Windows的版本 下载地址:http://www.oracle.com/technetwork/database/enterprise-edition/ ...
- VS2008/MVC2 项目迁移到 VS2013/MVC4
第1步.MVC2 => MVC3 手动处理可以参考这个: http://www.asp.net/whitepapers/mvc3-release-notes#upgrading 使用工具 ASP ...
- Service Discovery with Apache Curator
Curator的介绍 Curator就是Zookeeper的一个客户端工具(不知道Zookeeper的同学可以到http://www.ibm.com/developerworks/cn/opensou ...