Advertisement
Benlahbib_Abdessamad

Untitled

Sep 20th, 2015
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.72 KB | None | 0 0
  1.  
  2. public class Test {
  3.    
  4.    
  5.    
  6.    
  7.     public static void trie(int []tab,int size)
  8.     {
  9.         int i,j,temp;
  10.         for(i=0;i<size;i++)
  11.         {
  12.             for(j=0;j<size-1;j++)
  13.             {
  14.                 if(tab[j]>tab[j+1])
  15.                 {
  16.                     temp=tab[j];
  17.                     tab[j]=tab[j+1];
  18.                     tab[j+1]=temp;
  19.                 }
  20.             }
  21.         }
  22.     }
  23.    
  24.    
  25.         public static void main(String[] args){
  26.             int[] numbers= new int[100];
  27.             int position=0;
  28.             while(position<100){
  29.                 numbers[position]=(int)(10000*Math.random());
  30.                 System.out.print(numbers[position]+" ");
  31.                 position=position+1;
  32.             }
  33.             System.out.println();
  34.            
  35.             trie(numbers,numbers.length);
  36.            
  37.             for(int i=0;i<numbers.length;i++)
  38.             {
  39.                 System.out.print(numbers[i] + " ");
  40.             }
  41.            
  42.         }
  43.        
  44.        
  45.        
  46.        
  47.        
  48.    
  49.  
  50.    
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement