Lab Sorting
package ppp;
public class ArrayOfLength
{
public static void main (String[] arges)
{
int [] lenght= {45,54,87,78,99};
for(int i=0;i<5;i++)
{
for(int j=0;j<5;j++)
{
if(lenght[i]>lenght[j])
{
int a;
a=lenght[i];
lenght[i]=lenght[j];
lenght[j]=a;
}
}
}
for(int i=0;i<5;i++)
{
System.out.println(lenght[i]);
}
}
}
____________________________________________________________________
執行結果
99
87
78
54
45
0 Comments:
发表评论
<< Home