首页 > 代码库 > 插入排序_JAVA

插入排序_JAVA

public class Main {    public static void main(String[] args) {        int[] A = { 6, 4, 3, 5, 6, 2 };        for (int j = 1; j < A.length; j++) {            int key = A[j];            int i = j - 1;            while (i >= 0 && A[i] > key) {                A[i + 1] = A[i];                i--;            }            A[i + 1] = key;        }    }}        

 

插入排序_JAVA