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 } 

  • 相关阅读:
    git 学习
    ruby on rails 把阿里云上的图片资源转移到七牛云上写的一个task 文件 自动转移
    修改mysql的默认编码
    ruby on rails 安装中遇到的一些问题
    unity打包资源格式全解析
    unity打包全过程解析
    mmorpg手游中的战斗系统
    在线调试lua原型设计
    lua特性纪要
    软件开发中的哲学问题
  • 原文地址:https://www.cnblogs.com/angle-qqs/p/4051143.html
Copyright © 2011-2022 走看看