写出一个字符串,打印出字符串中字符的所有排序-递归
2016-03-19 22:33
399 查看
public static void main(String[] args) { String str = ""; Scanner scan = new Scanner(System.in); str = scan.nextLine(); permutation(str.toCharArray(), 0); } public static void permutation(char[] str, int i) { if (i >= str.length) return; if (i == str.length - 1) { System.out.println(String.valueOf(str)); } else { for (int j = i; j < str.length; j++) { char temp = str[j]; str[j] = str[i]; str[i] = temp; permutation(str, i + 1); temp = str[j]; str[j] = str[i]; str[i] = temp; } } }
相关文章推荐
- C语言之清空缓存区
- [Spark经验一]Spark RDD计算使用的函数里尽量不要使用全局变量
- android 关闭弹出键盘
- 轻量级应用开发之(01)第一个IOS程序
- hdu-5645 DZY Loves Balls(水题)
- 递归算法(JAVA)
- Android开发之assets目录下资源使用总结
- CDC,CPaintDC,CClientDC,CWindowDC区别
- CF 653E(Bear and Forgotten Tree 2-链表优化搜索)
- C++运算符优先级
- 206. Reverse Linked List | Java最短代码实现
- Win7下设置DirectShow编译环境小结(特别的x64位环境)
- EntityFramework 6.0 修改一个已经存在的对象
- 对glOrtho、glViewport函数的理解
- HDU 4766 模拟退火(最小圆覆盖) + 二分
- 在java中,final,finally,fanalize的区别
- mysql5.7安装手册
- shell程序分析--qcd
- iOS约束的设置
- VS2013+QT5 界面中文显示乱码问题 解决方案