int[] arr = new int[]{34,5,22,-98,6,-76,0,-3};
int temp = 0;
for(int i = 0;i < arr.length;i++){
for(int j = 0;j < i;j++){
if(arr[i] < arr[j]){
temp = arr[i];
arr[i] = arr[j];
arr[j] = temp;
}
}
}
for(int i = 0;i < arr.length;i++){
System.out.print(arr[i] + " ");
}
}
全部评论
(1) 回帖