Advertisement
Zeill

Ejercicio Clase

Oct 22nd, 2019
564
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.01 KB | None | 0 0
  1. import java.util.Arrays;
  2.  
  3. /**
  4.  *
  5.  * @author Fate
  6.  */
  7. public class Ejercicio {
  8.    
  9.     public static void main(String[] args) {
  10.        
  11.         int[] nums = {51,74,32,321,104,67};
  12.        
  13.         System.out.println("Array Desordenado: ");
  14.         System.out.println(Arrays.toString(nums));
  15.        
  16.         int num;
  17.         boolean orden = false;
  18.        
  19.         while (orden == false) {
  20.            
  21.             orden = true;
  22.            
  23.             for (int i = 0; i < nums.length -1; i++) {
  24.                
  25.                 if (nums[i] > nums[i+1]) {
  26.                    
  27.                     num = nums[i];
  28.                     nums[i] = nums[i+1];
  29.                     nums[i+1] = num;
  30.                     orden = false;
  31.                    
  32.                 }
  33.                
  34.             }
  35.            
  36.         }
  37.        
  38.         //Array Ordenado
  39.         System.out.println("Array Ordenado: ");
  40.         System.out.println(Arrays.toString(nums));
  41.        
  42.        
  43.     }
  44.    
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement