请问这算不算冒泡排序,运行结果也是对的
public static void main(String[] args) {
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] + " ");
}
#Java#
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] + " ");
}
}