Permutation of r elements out of n
问题 I have the following code for permutation. But it is throwing the below error. 11111 21111 31111 41111 51111 61111 71111 81111 91111 01111 Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 10 at Permutation.main(nPr_3.java:22) The code is HashSet<Integer[]> set = new HashSet<Integer[]>(); int[] values = {1, 2, 3, 4, 5, 6, 7, 8, 9, 0}; int n = values.length; int r = 5; int i[] = new int[r]; int rc = 0; for(int j=0; j<Math.pow(n,r); j++) { Integer[] e = new Integer[r]; while