• hdu 5082(水题)


    Love

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


    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
     
    取出'_'后面的串然后拼到一起。
    #include <iostream>
    #include <stdio.h>
    #include <math.h>
    #include <stdlib.h>
    #include <algorithm>
    #include <string.h>
    using namespace std;
    
    int main()
    {
        char s1[25],s2[25];
        while(scanf("%s %s",s1,s2)!=EOF){
            int len1 = strlen(s1);
            int len2 = strlen(s2);
            int cnt = 0,cnt1 = 0;
            bool flag = false;
            for(int i=0;i<len1;i++){
                if(s1[i]=='_') flag = true,i++;
                if(flag){
                    s1[cnt++] = s1[i];
                }
            }
            flag = false;
            for(int i=0;i<len2;i++){
                if(s2[i]=='_') flag = true,i++;
                if(flag){
                    s2[cnt1++] = s2[i];
                }
            }
            for(int i=0;i<cnt;i++) printf("%c",s1[i]);
            printf("_small_");
            for(int i=0;i<cnt1;i++) printf("%c",s2[i]);
            printf("
    ");
        }
        return 0;
    }
  • 相关阅读:
    [置顶] 宏途_LCD调试流程.
    字典树的数据结构及基本算法的实现
    uva 10714 Ants(贪心)
    paip.输入法编程---增加码表类型
    chomp方法
    ios 限制输入长度
    我所理解的设计模式(C++实现)——策略模式(Strategy Pattern)
    Android用户界面 UI组件--AdapterView及其子类(一) ListView及各种Adapter详解
    C#系列教程——switch定义及使用
    局域网内linux由ip反解析主机名
  • 原文地址:https://www.cnblogs.com/liyinggang/p/5657307.html
Copyright © 2020-2023  润新知