UVA 10361 串位置的交换
来源:互联网 发布:所罗门矩阵 编辑:程序博客网 时间:2024/06/08 12:22
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<iostream>#include<cstdio>#include<cstring>#include<cstdlib>using namespace std;char s[100][1000],s1[200],s2[200];int main(){ int n; while(~scanf("%d%*c",&n)) { while(n--) { fgets(s1,sizeof(s1),stdin); //存回车 fgets(s2,sizeof(s2),stdin); //回车占一个位 int len=strlen(s1); int p=0,num=0; for(int i=0;i<len;i++) { s[p][num++]=s1[i]; if(s1[i]=='<'||s1[i]=='>') { s[p][num-1]='\0'; //为了提取每个<span id="transmark"></span>单词 p++; num=0; } else printf("%c",s1[i]); } s[p][num]='\0'; //回车在字符尾部 <span id="transmark"></span> s2[strlen(s2)-4]='\0'; //cout<<s2; printf("%s%s%s%s%s",s2,s[3],s[2],s[1],s[4]); } }}
- UVA 10361 串位置的交换
- Table 的行交换位置
- 交换两个数的位置
- 交换两个数的位置
- 只含0、1的串进行排序,可任意交换位置,最小交换次数
- 可以拖动交换item位置的GridView
- 可以拖动交换item位置的GridView
- UITableView中Cell的位置交换
- NSMutableArray交换数组元素位置的方法
- UICollectionView的cell拖动交换位置
- 交换两个兄弟元素的位置
- 交换链表中相邻节点的位置
- 引用 交换两个数的位置
- 交换两个十六进制数的位置
- 将一个三位数的位置交换顺序
- UVA 331 交换的方案数
- 331UVA交换的方案数
- Android - 交换控件位置:基于LayoutParams的瞬间交换与基于ObjectAnimator动画效果交换
- 使用Struts2和jQuery EasyUI实现简单CRUD系统(三)——ajax,struts2使用json格式的交互
- 读写propert文件的例子
- 正则表达式在iOS中的运用
- 部分的开发文档接口
- 万向节死锁(Gimbal Lock)欧拉角表示旋转的缺陷
- UVA 10361 串位置的交换
- 性能之巅:洞悉系统、企业与云计算——互动出版网
- SpringMVC请求静态资源出现404从错误
- java 关键字final static 用法总结
- Studio如何导入jar和第三方库
- C语言 认识转换符 fscanf()用法
- Date 形式转换
- 在eclipse配置集成tomcat7,maven项目使用tomcat7运行
- 应用程序与数据库得匹配问题