题意翻译

给定两个用空格分隔的字符串,分别取两字符串的任意非空前缀,将两前缀合并为一个新的字符串,求可行字典序最小的字符串。

题目描述

The preferred way to generate user login in Polygon is to concatenate a prefix of the user's first name and a prefix of their last name, in that order. Each prefix must be non-empty, and any of the prefixes can be the full name. Typically there are multiple possible logins for each person.

You are given the first and the last name of a user. Return the alphabetically earliest login they can get (regardless of other potential Polygon users).

As a reminder, a prefix of a string ss is its substring which occurs at the beginning of ss : "a", "ab", "abc" etc. are prefixes of string "{abcdef}" but "b" and 'bc" are not. A string aa is alphabetically earlier than a string bb , if aa is a prefix of bb , or aa and bb coincide up to some position, and then aa has a letter that is alphabetically earlier than the corresponding letter in bb : "a" and "ab" are alphabetically earlier than "ac" but "b" and "ba" are alphabetically later than "ac".

输入输出格式

输入格式:

The input consists of a single line containing two space-separated strings: the first and the last names. Each character of each string is a lowercase English letter. The length of each string is between 1 and 10, inclusive.

输出格式:

Output a single string — alphabetically earliest possible login formed from these names. The output should be given in lowercase as well.

输入输出样例

输入样例#1: 复制

harry potter
输出样例#1: 复制

hap
输入样例#2: 复制

tom riddle
输出样例#2: 复制

tomr
 
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
string s1,s2;
int len1,len2,pos1,pos2;
int main(){
cin>>s1>>s2;
len1=s1.length()-;
len2=s2.length()-;pos1=;
while(s1[pos1]<s2[pos2]&&pos1<=len1) pos1++;
if(pos1){
for(int i=;i<pos1;i++) cout<<s1[i];
cout<<s2[];
return ;
}
}
 

最新文章

  1. linux 下链接无线网络
  2. gRpc NET Core
  3. MVC控制器取参数值
  4. python_way day13 paramiko
  5. NPOI相关
  6. c++函数重载---2
  7. poj2155 树状数组 Matrix
  8. Android 国际化图片资源文件
  9. SIGGRAPH
  10. js事件流、事件处理程序/事件侦听器
  11. 27个Jupyter Notebook使用技巧及快捷键(翻译版)
  12. 十九、Android Activity初探
  13. phpStorm打开提示 failed to create JVM 的解决的方法
  14. Modelsim使用笔记(一个完成工程的仿真)
  15. .net core自定义高性能的Web API服务网关
  16. JavaScript的工作原理:解析、抽象语法树(AST)+ 提升编译速度5个技巧
  17. Linux - rename 批量替换两种模式
  18. 访问服务器时一直在转圈,等待localhost响应
  19. bloomfilter 以及count min sketch
  20. JAVA面对对象(一)——封装

热门文章

  1. spring 获取对象方式
  2. 关于move_uploaded_file()出错的问题
  3. 【转】IOS中Json解析的四种方法
  4. Spring《八》AOP/代理类定义
  5. Install opencv on Centos
  6. html行级元素和块级元素以及css转换
  7. 12.javaweb SQL标签库
  8. 在MyEclipse中使用debug模式
  9. vue首次进入微信没有标题问题
  10. Surrogate data 代理数据