Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- int main()
- {
- //ressources
- int i,j;
- char *chaine[10];
- char buffer[500];
- int *tmp;
- int res;
- // On récupère 10 chaines de caractères.
- for (i=0; i<10; i++){
- fflush(stdin);
- gets(buffer);
- chaine[i] = (char *)malloc(strlen(buffer+1));
- strcpy(chaine[i],buffer);
- }
- // On tri nos 10 chaines
- for (i = 0; i<10; i++)
- {
- for (j=0;j<9;j++)
- {
- res = strcmp(chaine[j],chaine[j+1]);
- if(res>0)
- {
- tmp = chaine[j];
- chaine[j] = chaine [j+1];
- chaine[j+1] = tmp;
- }
- }
- }
- // Affichage tableau trié
- for(i=0;i<10;i++)
- printf("%s\n",chaine[i]);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement