//氣泡排序
int ary[] = {120,-10,-30,3,20,150,30,150};
int swap;
String temp = "";
for(int i = 0;i < ary.length;i++){
temp += ary[i]+"\t";
}
System.out.println("排序前的ary: "+temp);
temp="";
for(int i = 0;i < ary.length-1;i++){
if(ary[i] > ary[i+1]){
swap = ary [i];
ary[i] = ary[i+1];
ary[i+1] = swap;
}
}
for(int i = 0;i < ary.length; i++){
temp += ary[i]+"\t";
}
System.out.println("排序後的ary : "+temp);
標籤
Android
(
1
)
DbVisualizer
(
2
)
html/javascript
(
1
)
java
(
11
)
MySQL
(
1
)
oracle
(
1
)
servlet&jsp
(
3
)
struts
(
2
)
沒有留言 :
張貼留言