zoukankan      html  css  js  c++  java
  • BestCoder Round#15 1001-Love

    http://acm.hdu.edu.cn/showproblem.php?pid=5082

    Love

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


    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
     

    Source
     

     解题思路:题目已经告诉你怎么输出答案了0.0 -》 the format [first name of male]_small_[first name of female]. 

     1 #include <stdio.h>
     2 #include <string.h>
     3 
     4 int main(){
     5     char str1[50], str2[50], str3[50], str4[50];
     6     int len, i, j;
     7     while(scanf("%s %s", str1, str2) != EOF){
     8         len = strlen(str1);
     9         for(i = 0; i < len; i++){
    10             if(str1[i] == '_'){
    11                 break;
    12             }
    13         }
    14         i++;
    15         for(j = i; j < len; j++){
    16             str3[j - i] = str1[j];
    17         }
    18         str3[j - i] = '';
    19 
    20         len = strlen(str2);
    21         for(i = 0; i < len; i++){
    22             if(str2[i] == '_'){
    23                 break;
    24             }
    25         }
    26         i++;
    27         for(j = i; j < len; j++){
    28             str4[j - i] = str2[j];
    29         }
    30         str4[j - i] = '';
    31         printf("%s_small_%s ", str3, str4);
    32     }
    33     return 0;

    34 } 

  • 相关阅读:
    分布式协调服务 ( 服务治理 ).
    【Java常用类之enumm枚举类 20】
    【Java常用类之date类 19】
    【Java常用类之String类18】
    【Java数组算法17】
    【Java数组-二维数组16】
    【Java数组-一维数组15】
    【Java异常 14】
    【Java的package/import&访问权限&修饰符&Object常用方法 13】
    《Rubu基础教程第五版》第十七章笔记 IO类
  • 原文地址:https://www.cnblogs.com/angle-qqs/p/4051143.html
Copyright © 2011-2022 走看看