import?java.util.Scanner;
public?class?BubbleSort?{
public?static?int[]?BubbleSort(int[]?a){
int?temp;
for(int?j=?a.length-1;j>0;j--){
for(int?i?=?0;?i?<?a.length-1-j;i++){
if?(a[i+1]<a[i]){
temp?=?a[i+1];
????????a[i+1]=a[i];
????????a[i]=?temp;
}
}
}
return?a;
}
public?static?void?main(String[]?args){
Scanner?input=?new?Scanner(System.in);
System.out.println("please?enter?in?...");
int?[]?array?=?new?int?[10];
for(int?i?=?0;i<array.length-1;i++){
array[i]=input.nextInt();
}
?int?[]arr2?=new?int[10];
int[]?a=BubbleSort(array);
for(int?i?=?0;i<array.length-1;i++){
System.out.println(array[i]);
}
}
}
2 回答

JustWannaHugU
TA貢獻(xiàn)452條經(jīng)驗(yàn) 獲得超796個(gè)贊
同學(xué)代碼邏輯沒(méi)錯(cuò)啊,運(yùn)行也沒(méi)問(wèn)題,你遇到什么問(wèn)題了?
添加回答
舉報(bào)
0/150
提交
取消