java选择排序

代码
1 public class SelectSort {
2 public static void main(String[] args){
3 int[] sort={8,5,7,9,55};
4 Sort(sort);
5 for(int i=0;i<sort.length;i++)
6 System.out.print(sort[i]+" ");
7
8 }
9
10 public static void Sort(int[] sort){
11 for(int i=0;i<sort.length-1;i++){
12 for(int j=i+1;j<sort.length;j++){
13 if(sort[i]>sort[j]){
14 int temp;
15 temp=sort[i];
16 sort[i]=sort[j];
17 sort[j]=temp;
18 }
19 }
20 }
21 }
22 }

 

posted @ 2010-05-29 09:56  莫萧  阅读(3893)  评论(2编辑  收藏  举报