hdu 5082 Love(字符串处理)

Love

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 874    Accepted Submission(s): 535


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]
 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
题意:输出第一个字符串的名字+_small_+后一个字符串的名字

代码:

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
using namespace std;

int main()
{
    char a[25],b[25];
    while(~scanf("%s",a))
    {
        scanf("%s",b);
        int len=strlen(a),len1=strlen(b);
        int i,j;
        for(i=0;i<len;i++)
            if(a[i]=='_')
            break;
        for(j=0;j<len1;j++)
            if(b[j]=='_')
            break;
        for(int l=i+1;l<len;l++)
            printf("%c",a[l]);
        printf("_small_");
        for(int l=j+1;l<len1;l++)
            printf("%c",b[l]);
            printf("\n");
    }
    return 0;
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值