Advertisement
villers

Untitled

Nov 27th, 2013
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.72 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. void ordonnerTableau(int tableau[], int tailleTableau);
  5.  
  6. int main(void)
  7. {
  8.     int tableau[6] = {10, 15 , 66 , 22 , 13, 58}, i;
  9.     int taille = sizeof(tableau) / sizeof(int);
  10.  
  11.     ordonnerTableau(tableau, taille);
  12.  
  13.     for (i = 0; i < taille; i++)
  14.         printf("%d%s", tableau[i], (i == taille-1) ? "." : ", ");
  15.  
  16.     return 0;
  17. }
  18.  
  19. void ordonnerTableau(int tableau[], int tailleTableau)
  20. {
  21.     int i,j,k;
  22.  
  23.     for (i = 0; i < tailleTableau; i++)
  24.         for (j = 0; j < tailleTableau-1; j++)
  25.             if(tableau[j] > tableau[j+1])
  26.             {
  27.                k = tableau[j];
  28.                tableau[j] = tableau[j+1];
  29.                tableau[j+1] = k;
  30.             }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement