Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void main(String[] args) {
- int[] numeros = {5,8,17,1,3,9,12};
- bubbleSort(numeros);
- for (int numero : numeros) {
- System.out.print(numero + ",");
- }
- }
- static void bubbleSort(int[] arr) {
- int n = arr.length;
- int temp = 0;
- for(int i=0; i < n; i++){
- for(int j=1; j < (n-i); j++){
- if(arr[j-1] > arr[j]){
- //Intercambiar Elementos
- temp = arr[j-1];
- arr[j-1] = arr[j];
- arr[j] = temp;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement