Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- void main(){
- char chaine[]={'z','x','a','o','m','g'};// chaine non triée
- 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]){
- char tmp;
- 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",chaine);
- system("pause");
- }
Advertisement
Add Comment
Please, Sign In to add comment