⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 insertsort.java

📁 企业培训过程中的记录,希望对找工作的朋友帮助.
💻 JAVA
字号:
public class InsertSort{
	public static void insertSort(int[] a){
		int i, j, temp;
		int n = a.length;
		
		for(i = 0; i < n - 1; i ++){
		temp = a[i + 1];
		j = i;
		while(j > -1 && temp <= a[j]){
			a[j + 1] = a[j];
			j --;
		}
		a[j + 1] = temp;
		}
	}
	
	public static void main(String[] args){
		int[] test = {64, 5, 7, 89, 6, 24};
		int n = test.length;
		
		insertSort(test);
		for(int i = 0; i < n; i ++)
			System.out.print(test[i] + "  ");
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -