Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- // Page : Langage C
- // Link : http://www.facebook.com/MOBY.c00
- // JOIN US
- */
- #include <stdio.h>
- #include <string.h>
- void main(){
- char chaine[]="xnoadbkie";// chaine non triée
- char tmp;
- int i,test=1;// la variable test pour verifier si le tableau est trié ou pas encore
- do{
- test=0;
- for(i=1;i<strlen(chaine);i++){
- if(chaine[i]<chaine[i-1])
- {
- tmp = chaine[i];
- chaine[i]=chaine[i-1];
- chaine[i-1]=tmp;
- test = 1; // On a fait un trie donc on continue la boucle
- }
- }
- }while(test);
- printf("la chaine triée %s\n",chaine);
- system("pause");
- }
Advertisement
Add Comment
Please, Sign In to add comment