SHOW:
|
|
- or go back to the newest paste.
| 1 | /* | |
| 2 | // Page : Langage C | |
| 3 | // Link : http://www.facebook.com/MOBY.c00 | |
| 4 | // JOIN US | |
| 5 | - | char chaine[]={'z','x','a','o','m','g'};// chaine non triée
|
| 5 | + | */ |
| 6 | - | int i,test=1;// la variable test pour verifier si le tableau est trié ou pas encore |
| 6 | + | |
| 7 | #include <stdio.h> | |
| 8 | #include <string.h> | |
| 9 | ||
| 10 | - | if(chaine[i]<chaine[i-1]){
|
| 10 | + | |
| 11 | - | char tmp; |
| 11 | + | char chaine[]="xnoadbkie";// chaine non triée |
| 12 | char tmp; | |
| 13 | int i,test=1;// la variable test pour verifier si le tableau est trié ou pas encore | |
| 14 | do{
| |
| 15 | test=0; | |
| 16 | for(i=1;i<strlen(chaine);i++){
| |
| 17 | if(chaine[i]<chaine[i-1]) | |
| 18 | - | |
| 18 | + | {
|
| 19 | tmp = chaine[i]; | |
| 20 | chaine[i]=chaine[i-1]; | |
| 21 | - | printf("la chaine triée %s",chaine);
|
| 21 | + | |
| 22 | test = 1; // On a fait un trie donc on continue la boucle | |
| 23 | } | |
| 24 | } | |
| 25 | }while(test); | |
| 26 | printf("la chaine triée %s\n",chaine);
| |
| 27 | system("pause");
| |
| 28 | ||
| 29 | ||
| 30 | } |