C#算法,在一个字符串重新排列个字符 [英] C# Algorithm that Re-arranges Chars in a String

查看:297
本文介绍了C#算法,在一个字符串重新排列个字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想一个C#的算法,重新排列字符的字符串,它是动态的长度。很难找到一个,我知道必须有一出在那里。

I would like a C# algorithm that re-arranges the chars in a string that is dynamic in length. Having trouble finding one and I know there has to be one out there.

该算法重新调整元件以形成在所有可能的组合的新的字符串

The algorithm has to realign elements to form new strings in all possible combinations.

例如,猫将产生如下:
猫CTA TCA TAC行为ATC

For instance, "cat" would produce the following:
cat cta tca tac act atc

推荐答案

这是一个相当常见的问题在这里。尝试做的置换搜索,你会发现很多有关如何做到这一点的各种语言很好的答案。

This is a fairly frequently asked question here. Try doing a search on "permutation" and you'll find a lot of good answers about how to do this in various languages.

还有就是排列组合的算法在C#这里的库:

There is a library of permutation and combination algorithms in C# here:

HTTP://www.$c$cproject.com/KB/食谱/ Combinatorics.aspx

这篇关于C#算法,在一个字符串重新排列个字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆