Advertisement
Benlahbib_Abdessamad

Untitled

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