public class MaoPao02 {
public static void main(String[] args) {
int [] arr ={5,8,54,84,26};
maoPao(arr);
System.out.println(Arrays.toString(arr));
}
public static void maoPao(int [] arr){
for(int i=0;i<arr.length;i++){
for (int j = 0; j < arr.length-i-1; j++) {
if(arr[j] > arr[j+1]){
int temp = arr[j+1];
arr[j+1] =arr[j];
arr[j] = temp;
}
}
}
}
} |
|