### Question:
SelectIndexDataActivity extends BaseActivity { public static int partition(int[] a, int p, int r) { int x = a[r]; int i = p - 1; for (int j = p; j < r; j++) { if (a[j] <= x) { i = i + 1; swap(a, i, j); System.out.println("交换=" + "i=" + i + Arrays.toString(a)); }else{ System.out.println("未交换=" + "i=" + i + Arrays.toString(a)); } } swap(a, i + 1, r); System.out.println("结果=" + "i=" + i + Arrays.toString(a)); return i + 1; }  static int partition(int[] a, int p, int r); static int randomizedSelect(int[] a, int p, int r, int i);  }### Answer:
@Test public void testPartition() throws Exception{ int a[]={2,5,3,0,2,3,0,3}; int b[]={9,6,7,3,8,2,4,5}; int c[]={1,2,3,4,5,6,7,9}; int result = selectIndexDataActivity.partition(b,0,b.length-1); System.out.println("result =" + result); Random random = new Random(); }