Love丶FFC's Blog
给一组整数,按照升序排序,使用选择排序,冒泡排序,插入排序或者任何 O(n2) 的排序算法。
样例1
输入: [3, 2, 1, 4, 5]
输出: [1, 2, 3, 4, 5]
样例解释:
返回排序后的数组。
样例2
输入: [1, 1, 2, 1, 1]
输出: [1, 1, 1, 1, 2]
样例解释:
返回排好序的数组。
1.冒泡排序
2.使用双层for循环逐一比较各个元素的大小,并交换次序。
package Lintcode; import java.util.Arrays; public class _463 { public static void main(String[] args) { int[] Number = new int[] {1,9,3,4,5}; for(int i=0;i<Number.length;i++) { for(int j=i;j<Number.length;j++) //j=0换成j=i可减少循环次数 { if(Number[i]>Number[j]) { int swap; swap=Number[i]; //交换次序 Number[i]=Number[j]; Number[j]=swap; } } } System.out.println(Arrays.toString(Number)); } }
public class Solution { public void sortIntegers(int[] A) { for(int i=0;i<A.length;i++) { for(int j=i;j<A.length;j++) { if(A[i]>A[j]) { int swap; swap=A[i]; A[i]=A[j]; A[j]=swap; } } } System.out.println(Arrays.toString(A)); } }
fruinly
MCF7 T cells growth rate was almost doubled compared with parental, while T47D T and BT 474 T decreased compared with parental lines where to buy cialis cheap
FoorryNox
2F, suggesting that triptonide is a novel, potent inhibitor of TNBC cell vascular mimicry cialis viagra combo pack
Preliaf
cialis online ordering MA Cobleigh, CL Vogel, D Tripathy, etal Multinational study of the efficacy and safety of humanized anti HER2 monoclonal antibody in women who have HER2 overexpressing metastatic breast cancer that has progressed after chemotherapy for metastatic disease J Clin Oncol 17 2639 2648, 1999 Link, Google Scholar 15