黑马程序员技术交流社区
标题:
输入abc 可以输出其不同的排序,这段代码不是很懂,求解释
[打印本页]
作者:
小悠久
时间:
2014-1-3 20:52
标题:
输入abc 可以输出其不同的排序,这段代码不是很懂,求解释
public class Test13
{
public static String str = "abc";
public static void main(String[] args)
{
Shuffle(0, new String(""));
}
public static void Shuffle(int current_recur, String temp)
{
if(current_recur < str.length())
{
for(int i = 0; i < str.length(); i++)
{
if( ! ( temp.contains(str.substring(i, i + 1)) ) )
{
System.out.println(temp + str.substring(i, i + 1));
Shuffle(current_recur + 1, new String(temp + str.substring(i, i + 1)));
}
}
}
}
}
欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/)
黑马程序员IT技术论坛 X3.2