java 定义一个10个元素组成的一堆数组,输出该数组中的最大值,最小值,所

2024-12-01 07:12:02
推荐回答(1个)
回答(1):

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 // System.out.print(shu[l]+"\t");
for (int l:shu){
//System.out.print(l+"\t");
System.out.print("第"+l+"个数为:"+l);

}

}