日期:2014-05-18  浏览次数:20946 次

求一算法: C#
接受输入字符串:abc
输出结果:abc acb bac bca cab cba
谢谢指教,C#语言实现!

------解决方案--------------------
下班了,回去给你写...
------解决方案--------------------
public void permute1(String str)
{
char[] strArray = str.ToCharArray();
permute(strArray, 0, strArray.Length - 1);
}

public void permute(char[] list, int low, int high) { 
int i; 
if (low == high) { 
string cout = ""; 
for (i = 0; i <= high; i++) 
cout += list[i]; 
//System.out.println(cout); 
Response.Write(cout);
} else { 

for (i = low; i <= high; i++) { 
char temp = list[low]; 
list[low] = list[i]; 
list[i] = temp; 
permute(list, low + 1, high); 
temp = list[low]; 
list[low] = list[i]; 
list[i] = temp; 


}