摘要: 如果这样:private static int unsorted[];for(int i = 1 ; i < 8 ; i ++ )unsorted[i] = 1 ; 是会报NullPointerException的,原因很简单,数组没有初始化!unsorted没有申请到内存空间,for(..)里面的... 阅读全文
posted @ 2014-06-13 21:49 LarryLawrence 阅读(417) 评论(0) 推荐(0)
摘要: 位置p上的元素存储于tmp(第一趟p通常取1),而(位置p之前)所有更大的元素都向右移动一个位置。然后tmp被放在正确的位置上。代码:public class InsertionSort { private int q; int[] insertionSort(int[] a) { for (in... 阅读全文
posted @ 2014-06-13 20:54 LarryLawrence 阅读(193) 评论(0) 推荐(0)