bouchnina

Untitled

May 24th, 2013
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.52 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. void main(){
  5.     char chaine[]={'z','x','a','o','m','g'};// chaine non triée
  6.     int i,test=1;// la variable test pour verifier si le tableau est trié ou pas encore
  7.     do{
  8.         test=0;
  9.         for(i=1;i<strlen(chaine);i++){
  10.             if(chaine[i]<chaine[i-1]){
  11.                 char tmp;
  12.                 tmp = chaine[i];
  13.                 chaine[i]=chaine[i-1];
  14.                 chaine[i-1]=tmp;
  15.                 test = 1; // On a fait un trie donc on continue la boucle
  16.                 }
  17.         }
  18.        
  19.  
  20.     }while(test);
  21. printf("la chaine triée %s",chaine);
  22. system("pause");
  23.  
  24.  
  25. }
Advertisement
Add Comment
Please, Sign In to add comment