对n个不同正数进行排列,一共有多少种排列方式

import java.util.Scanner; public class NumberGroup { public static void main(String[] args) {System.out.println("请输入一个正数"); Scanner scan = new Scanner(System.in); int n = scan.nextInt(); int[] a = new int[n]; int[] b = new int[a.length]; System.out.println("请输入"+ n +"个正数"); for(int i=0; i

} } public static void numberGroup(int num, int[] a, int count, int[] b) { b[count] = num; count++; if (count >= a.length) {//递归的出口 for (int i = 0; i < b.length; i++) { System.out.print(b[i] + " "); if (i == b.length - 1) System.out.println(); }// b[count - 1] = 0; return; }for (int i = 0; i < a.length; i++) { if (!jiancha(b, a[i])) { numberGroup(a[i], a, count, b); qingchu(count, b); //关键 } } } public static boolean jiancha(int[] b, int x) { for (int i = 0; i < b.length; i++) { if (b[i] == x) { return true; } } return false; } public static void qingchu(int count, int[] b) {for (int j = count; j < b.length; j++) { b[j] = 0; } }}

【对n个不同正数进行排列,一共有多少种排列方式】

    推荐阅读