帮忙看一下,string concatenation

cross2 2009-03-01 08:11:08
问题如下:

String concatenation
Write a program that will accept two strings (1 <= length <= 50) and output the sequence of the first string converting to the second string, such that each conversion only add/modify/delete one character. In case more than one such conversion sequence is possible, print the one sequence that contains the shortest steps.

Input specification:
Two strings separated by space on a single line.

Output Specification:
The sequence of conversion steps, each in a separate line.

Examples:

Input:
abcd afgd

Output:
abcd
afcd
afgd

Input:
efgh cdef

Output:
efgh
efg
ef
def
cdef

Input:
abcdefg bdf

Output:
abcdefg
bcdefg
bdefg
bdfg
bdf


希望高手提供个思路,谢谢。
...全文
117 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
jakqigle 2009-03-01
  • 打赏
  • 举报
回复
简单想的话,对于第一个串与第二个比较匹配,匹配相同的串不动,其余不匹配的串再通过加减删除使第一个string向第二个转换。
cross2 2009-03-01
  • 打赏
  • 举报
回复
>>ACM啊?lz新手吧?

学校的作业,但是一点头绪也没有。帮忙看看吧,应该如何入手呢?
jakqigle 2009-03-01
  • 打赏
  • 举报
回复
ACM啊?lz新手吧?

64,637

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧