标签:
1 public class Inser { 2 public static void main(String args[]) { 3 int score[] = { 36, 27, 9, 18, 40 }; 4 for (int i = 1; i <= 4; i++) { 5 int t = score[i]; 6 int j = i - 1; 7 for (j = i - 1; j >= 0 && t < score[j]; j--) { 8 score[j + 1] = score[j]; 9 } 10 score[j + 1] = t; 11 12 } 13 print(score); 14 } 15 16 public static void print(int score[]) { 17 for (int i = 0; i < score.length; i++) { 18 System.out.print(score[i] + "\t"); 19 } 20 } 21 }
标签:
原文地址:http://www.cnblogs.com/gantanhao/p/5103023.html