方法一: >>> mylist = [1,2,2,2,2,3,3,3,4,4,4,4] >>> myset = set(mylist) >>> for item in myset: print("the %d has found %d" %(item,mylist.count(item))) the 1 has found 1 the 2 has found 4 the 3 has found 3 the 4 has found 4
代码如下: public class MergeSort { public static void sort(int [] A,int p, int r) { if(p<r) { int q = (int) Math.floor( (p+r)/2 ); sort(A,p,q); sort(A,q+1,r); merge(A,p,q,r); } return ; } public static void merge(int [] A, int p, int q, int r) { int n1 =