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("\n");
    }
    return 0;
}
时间: 07-09

hdu 5082(水题)的相关文章

hdu 4416 水题 浙大计算机研究生复试上机考试-2005年 可是发现自己写代码有问题

Spring3与Hibernate4整合时出现了nested exception is java.lang.NoClassDefFoundError: Lorg/hibernate/cache/CacheProvider. hibernate3的时候,用spring来控制sessionfactory用的可以是org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean,因为用的是hibernate4所以照猫画

hdu 2710 水题

题意:判断一些数里有最大因子的数 水题,省赛即将临近,高效的代码风格需要养成,为了简化代码,以后可能会更多的使用宏定义,但是通常也只是快速拿下第一道水题,涨自信.大部分的代码还是普通的形式,实际上能简化的部分也不太多 1 #include<iostream> 2 #include<cstring> 3 #include<cmath> 4 #include<cstdio> 5 using namespace std; 6 #define for0n for(i

Dijkstra算法---HDU 2544 水题(模板)

/* 对于只会弗洛伊德的我,迪杰斯特拉有点不是很理解,后来发现这主要用于单源最短路,稍稍明白了点,不过还是很菜,这里只是用了邻接矩阵 套模板,对于邻接表暂时还,,,没做题,后续再更新.现将这题贴上,应该是迪杰斯特拉最水的题没有之一.纯模板 */ 题目大意: 搬东西很累,想省力,给你几个点和点之间的距离:标准题型: #include<stdio.h> #include <iostream> #include<string.h> using namespace std; #

hdu 5162(水题)

题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5162 题解:看了半天以为测试用例写错了.这题玩文字游戏.它问的是当前第i名是原数组中的第几个. #include<stdio.h> #include<iostream> #include<string.h> #include <stdlib.h> #include<math.h> #include<algorithm> #include

HDU2109 Fighting for HDU【水题】

Fighting for HDU Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 7486    Accepted Submission(s): 3854 Problem Description 在上一回,我们让你猜测海东集团用地的形状,你猜对了吗?不管结果如何,都没关系,下面我继续向大家讲解海东集团的发展情况: 在最初的两年里,HDU

hdu 5038 水题 但是题意坑

http://acm.hdu.edu.cn/showproblem.php?pid=5038 就是求个众数  这个范围小 所以一个数组存是否存在的状态就行了 但是这句话真恶心  If not all the value are the same but the frequencies of them are the same, there is no mode. 其实应该是这个意思: 当频率最高的有多个的时候, 如果 所有的grade出现的频率都是相等的,那么是没有mode的 否则按照升序 当然

hdu 4737水题

http://acm.hdu.edu.cn/showproblem.php?pid=4737 [题意]:给出a数组和m,求 f(i, j) = ai|ai+1|ai+2| ... | aj   ,f(i, j) < m的i j 对数  1 #include<iostream> 2 #include<algorithm> 3 #include<cstdio> 4 #include<cstring> 5 using namespace std; 6 #de

hdu 5062(水题)

Beautiful Palindrome Number Time Limit: 3000/1500 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1067    Accepted Submission(s): 691 Problem Description A positive integer x can represent as (a1a2…akak…a2a1)10 or (a

hdu 4274 Spy&amp;#39;s Work(水题)

Spy's Work Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1266    Accepted Submission(s): 388 Problem Description I'm a manager of a large trading company, called ACM, and responsible for the

hdu 5210 delete 水题

Delete Time Limit: 1 Sec  Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5210 Description wld有n个数(a1,a2,...,an),他希望进行k次删除一个数的操作,使得最后剩下的n−k个数中有最多的不同的数,保证1≤n≤100,0≤k<n,1≤ai≤n(对于任意1≤i≤n) Input 多组数据(最多100组)对于每组数据:第一行:一个数n表示数的个数接下来一行: