星期一, 6月 05, 2006

LabSorb

package lab7;

public class LabSort
{
public static void main(String[] args)
{
int [] sort = {1,3,5,4,9};
int x=0;
for(int cont1=0;cont1 {
for (int cont2=cont1+1;cont2 {
if (sort[cont1] > sort[cont2])
{
x = sort[cont1];
sort[cont1] = sort[cont2]; //可知i
sort[cont2] = x; //可知j
}
}


}
for(int i=0;i {
System.out.print(sort[i]+",");
}
}
}

0 Comments:

張貼留言

<< Home

Creative Commons License
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 2.5 Taiwan License.