数组及其排序.ppt
数组及其排序 Still waters run deep.流静水深流静水深,人静心深人静心深 Where there is life,there is hope。有生命必有希望。有生命必有希望数组的声明与初始化n一维数组的声明方式:type var;或或 type var;n数组的初始化:数组名数组名=new 数组元素的类型数组元素的类型 元素个数元素个数;数组的声明与初始化示例01234S:S0S1S2S3S4其它示例其它示例排序算法n冒泡排序n选择排序n插入排序nShell 排序排序示例冒泡排序演示n1,5,6,12,4,9,3,23,39,403,596,87n1,4,6,12,5,9,3,23,39,403,596,87n1,3,6,12,5,9,4,23,39,403,596,87n1,3,5,12,6,9,4,23,39,403,596,87n1,3,4,12,6,9,5,23,39,403,596,87n1,3,4,6,12,9,5,23,39,403,596,87冒泡排序算法程序选择排序算法程序选择排序演示第一轮,寻找最小值并交换到第一位n1,5,6,12,4,9,3,23,39,403,596,87第二轮,寻找最小值并交换到第二位n1,3,6,12,4,9,5,23,39,403,596,87第三轮,寻找最小值并交换到第三位n1,3,4,12,6,9,5,23,39,403,596,87第四轮,寻找最小值并交换到第四位n1,3,4,5,6,9,12,23,39,403,596,87插入排序算法Shell 排序算法Arrays 类的 sort 方法参考文档:http:/ 接口接口