HDU 5082 Love
2015-08-21 10:30
417 查看
Love
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 763 Accepted Submission(s): 455
Problem Description
There is a Love country with many couples of Darby and Joan in it. In order to commemorate their love, they will do some thing special when giving name to their offspring.
When a couple want to give name to their offspring, they will firstly get their first names, and list the one of the male before the one of the female. Then insert the string “small” between their first names. Thus a new name is generated. For example, the
first name of male is Green, while the first name of the female is Blue, then the name of their offspring is Green small Blue.
You are expected to write a program when given the name of a couple, output the name of their offsping.
Input
Multi test cases (about 10), every case contains two lines.
The first line lists the name of the male.
The second line lists the name of the female.
In each line the format of the name is [given name]_[first name].
Please process to the end of file.
[Technical Specification]
3 ≤ the
length of the name ≤ 20
[given name] only contains alphabet characters and should not be empty, as well as [first name].
Output
For each case, output their offspring’s name in a single line in the format [first name of male]_small_[first name of female].
Sample Input
Jim_Green Alan_Blue
Sample Output
Green_small_Blue
Source
BestCoder Round #15
Recommend
heyang | We have carefully selected several similar problems for you: 5416 5415 5414 5413 5412
纯属字符串水题!!!
题目意思很简单,给出父母的名字,帮孩子取名字。
简化一下就是:孩子的名字=[父亲的frist name]_small_[母亲的frist name];
然后再输出孩子的名字就可以了。
//AC: 15MS 1712K #include<cstring> #include<cstdio> char fa[50],mo[50]; int main() { while(~scanf("%s%s",fa,mo)) { int sign; int la=strlen(fa); int lb=strlen(mo); for(int i=0; i<la; i++) { if(fa[i]>='A' && fa[i]<='Z' || fa[i]>='a' && fa[i]<='z') continue; else{ sign=i; break; } } printf("%s%c",fa+sign+1,fa[sign]); printf("small"); for(int i=0; i<lb; i++){ if(mo[i]>='A' && mo[i]<='Z' || mo[i]>='a' && mo[i]<='z') continue; else { sign=i; break; } } printf("%s\n",mo+sign); } return 0; }
以上为练习赛时的代码,事后想想发现还可以更简短:
//AC: 0MS 1708K #include<cstring> #include<cstdio> char fa[50],mo[50]; int main() { while(~scanf("%s",fa)){ int la = 0,lb = 0; while(fa[la++] != '_'); if(!~scanf("%s",mo)) break; while(mo[lb++] != '_'); printf("%s_small_%s\n",fa+la,mo+lb); } return 0; }
相关文章推荐
- java调用mysql的存储过程
- SQLAlchemy 学习(一)
- poj 1068 Parencodings
- 排错记录:plsql无法连接oracle ora-12154 ora-12560
- MyEclipse、Eclipse SVN插件的帐号、密码修改
- 使用SQL脚本访问操作远程数据库
- android--textView添加html超链接响应
- 学习Spring笔记_Annotation(注解)_Component
- 中国人靠手机享受丰富生活?你没看到背后的折腾
- 亿级Web系统搭建——单机到分布式集群
- 接口函数开发总结
- 关于Android中fragment中创建popwindow全屏显示时手机状态遮挡popwindow的问题
- POJ 2312 Battle City BFS+优先队列
- VS错误 FileTracker : error FTK1011:
- 解决使用findnext相关函数在64位编译环境下遍历文件夹下的文件
- tar 命令
- [转] 自定义取色函数
- [LeetCode] Find Minimum in Rotated Sorted Array
- android:修改PagerTabStrip中的背景颜色,标题字体的样式、颜色和图标以及指示条的颜色
- MVC中用View.bag保存json字符串。在js中使用,不用ajax请求。。。。