Love
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 703 Accepted Submission(s): 410
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
Source
题意:用两个姓氏连在一起,中间用small间隔
题目分析: 模拟即可
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
using namespace std;
char ans[500], s[500];
char pattern[] = "_small_";
int main ( )
{
while ( ~scanf ( "%s" , s ) )
{
int i = 0;
while ( s[i] )
if ( s[i++] == '_' ) break;
int j = 0;
while ( s[i] )
ans[j++] = s[i++];
i = 0;
while ( pattern[i] )
ans[j++] = pattern[i++];
i = 0;
scanf ( "%s" , s);
while ( s[i] )
if ( s[i++] == '_' ) break;
while ( s[i] )
ans[j++] = s[i++];
ans[j] = 0;
printf ( "%s\n" , ans );
}
}
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
using namespace std;
char ans[500], s[500];
char pattern[] = "_small_";
int main ( )
{
while ( ~scanf ( "%s" , s ) )
{
int i = 0;
while ( s[i] )
if ( s[i++] == '_' ) break;
int j = 0;
while ( s[i] )
ans[j++] = s[i++];
i = 0;
while ( pattern[i] )
ans[j++] = pattern[i++];
i = 0;
scanf ( "%s" , s);
while ( s[i] )
if ( s[i++] == '_' ) break;
while ( s[i] )
ans[j++] = s[i++];
ans[j] = 0;
printf ( "%s\n" , ans );
}
}