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

📄 sort.java

📁 算法导论上机作业java实现
💻 JAVA
字号:

public class sort {
	
	
	public static void main(String[] args) {
		int[] array = {2,4,5,3,1,6};
		int temp =0;
		for(int i =0;i<6;i++){
			 temp = array[array[i]-1]; 
			 array[array[i]-1]=array[i] ;
			 array[i]= temp;
			//temp = array[i];
			//array[i] = array[array[i]-1];
			//array[array[i]-1]= temp;
			 
		}
		
			System.out.println("The sorted array is:");
			for(int i =0;i<6;i++){
				System.out.println(array[i]);
		}

	}

}

⌨️ 快捷键说明

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