Advertisement
Glaas2

Orden Alfabetico

Sep 19th, 2012
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.47 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4.  
  5. int main()
  6. {
  7. char nombre[3][20];
  8. char aux[20];
  9. int i, j;
  10.  
  11. for(i=0; i<3; i++)
  12. {
  13. printf("Introduce nombre %d : ", i+1);
  14. fflush(stdin);
  15. gets(nombre[i]);
  16. }
  17.  
  18. for(i=0; i<2; i++)
  19. for(j=i+1; j<3; j++)
  20. if(strcmp(nombre[i], nombre[j]) > 0)
  21. {
  22. strcpy(aux, nombre[i]);
  23. strcpy(nombre[i], nombre[j]);
  24. strcpy(nombre[j], aux);
  25. }
  26.  
  27. for(i=0; i<3; i++)
  28. printf("\n %s\n", nombre[i]);
  29. system("pause");
  30. return 0;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement