daily pastebin goal
15%
SHARE
TWEET

Untitled

a guest Dec 13th, 2018 60 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package modelo;
  2.  
  3. import java.util.ArrayList;
  4. import java.util.Arrays;
  5. import java.util.Collections;
  6. import java.util.Vector;
  7.  
  8. /**
  9.  *
  10.  * @author herquiloide
  11.  */
  12. public class OrdenarNumerosArray {
  13.     public static void main(String[] args) {
  14.        
  15.         Vector<Integer> v  = new Vector(Arrays.asList(12, 8, 6, 10, 23, 14));
  16.        
  17.         System.out.println("K | " + "aux | " + "j | "+ "(j>=0 && v[j] > aux) | " + "v[j+1] = v[j] | "+ "v[j+1] = aux" + "        V     " );
  18.  
  19.         for (int k = 1; k < v.size(); k++){
  20.             int aux = v.get(k);
  21.             int j = k - 1;
  22.             boolean condicao = j>=0 && v.get(j) > aux;
  23.            
  24.             while(j>=0 && v.get(j) > aux){
  25.                 v.set(j+1, v.get(j));
  26.      
  27.                 System.out.println(k + "   " + aux + "     "+ j + "    "+ condicao+ "                       " +v.get(j) + "                "+ aux + "         " + v.toString() );
  28.                 j = j - 1;
  29.                
  30.      
  31.  
  32.             }
  33.            
  34.             v.set(j+1, aux);
  35.         }
  36.        
  37.     }
  38.  
  39.  
  40. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top