Advertisement
Guest User

Untitled

a guest
Aug 25th, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include <stdbool.h>
  5. #include <string.h>
  6. #include <locale.h>
  7. #include <windows.h>
  8.  
  9. int main()
  10. {
  11. char texto[50000];
  12. int n;
  13. int i=1;
  14. char palabra[500];
  15. printf("Introduce el texto que deseas ordenar alfabeticamente\n");
  16. gets(texto);
  17. printf("%s\n", texto);
  18. for(n=0; n<=texto;n++){
  19. /*if(texto[n] == ' '){
  20. printf("Espacio");
  21. }*/
  22. if (texto[n] != ' ') {
  23. palabra[i] = texto[n];
  24. }
  25. else{
  26. i++;
  27. }
  28. }
  29.  
  30. int j, h, temp[50];
  31. for(j=0; j<i; j++){
  32. for(h=h; h<i; h++){
  33. if(strcmp(palabra[j], palabra[h])>0){
  34. strcpy(temp, palabra[j]);
  35. strcpy(palabra[j], palabra[h]);
  36. strcpy(palabra[h], temp);
  37. }
  38. }
  39. }
  40. printf("Los nombres ordenados son:\n");
  41. for(i=0; i<h; i++){
  42. printf("%s\t", palabra[i]);
  43. }
  44.  
  45. return 0;
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement