2个回答
展开全部
int []shu ={30,80,96,45,8,35};
for (int i=0;i<(shu.length-1);i++){
for (int p=0;p<(shu.length-1-i);p++){
if (shu[p]>shu[p+1]){
int huan=shu[p];
shu[p]=shu[p+1];
shu[p+1]=huan;
}
}
}
//输出冒泡排序的数组
//for (int l=0;l<shu.length;l++){
// System.out.print(shu[l]+"\t");
for (int l:shu){
//System.out.print(l+"\t");
System.out.print("第"+l+"个数为:"+l);
}
}
for (int i=0;i<(shu.length-1);i++){
for (int p=0;p<(shu.length-1-i);p++){
if (shu[p]>shu[p+1]){
int huan=shu[p];
shu[p]=shu[p+1];
shu[p+1]=huan;
}
}
}
//输出冒泡排序的数组
//for (int l=0;l<shu.length;l++){
// System.out.print(shu[l]+"\t");
for (int l:shu){
//System.out.print(l+"\t");
System.out.print("第"+l+"个数为:"+l);
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询