九九碗小葱是脂粉吗:10个数的排序用JAVA语言怎么写

来源:百度文库 编辑:高校问答 时间:2024/05/05 19:13:11

class paixu
{
private int i,j,temp;
void sort(int arrayOflnts[])
{
for(i=0;i<arrayOflnts.length-1;i++)
{
for(j=0;j<arrayOflnts.length-i-1;j++)
{
if(arrayOflnts[j]>arrayOflnts[j+1])
{
temp=arrayOflnts[j];
arrayOflnts[j]=arrayOflnts[j+1];
arrayOflnts[j+1]=temp;
}
}
}
}
void display(int arrayOflnts[])
{
for(i=0;i<arrayOflnts.length;i++)
{
System.out.println(arrayOflnts[i]);
}
}
}
public class p47_3
{
public static void main(String[] args)
{
int arrayOflnts[]={32,87,3,589,12,1076,2000,8,622,127};
paixu p=new paixu();
System.out.println("排序后的数组为:");
p.sort(arrayOflnts);
p.display(arrayOflnts);
}
}