在Merge Sort的基础上改改就好了. public class Inversions { public static int inversions(int [] A,int p, int r) { if(p<r) { int q = (int) Math.floor( (p+r)/2 ); int left = inversions(A,p,q); int right = inversions(A,q+1,r); int c = combine(A,p,q,r); return left…