fork download
  1. #include <string.h>
  2. #include <stdlib.h>
  3. #include <stdio.h>
  4. #include <ctype.h>
  5.  
  6. char *strtolower(char *str) {
  7. char *ptr = str;
  8.  
  9. while(*ptr != '\0') {
  10. *ptr = tolower(*ptr);
  11. ++ptr;
  12. }
  13.  
  14. return str;
  15. }
  16.  
  17. int main ()
  18. {
  19. int z=0,n=0,i=0,j=0,o=0,k=0,l=0;
  20. char t[20000][31];
  21. char v[31];
  22. char s[31];
  23.  
  24.  
  25. scanf ("%d",&z);
  26.  
  27. for (l=1;l<=z;l++)
  28. {
  29.  
  30. scanf ("%d\n",&n);
  31.  
  32. for (j=0;j<=n-1;j++)
  33. {
  34. scanf ("%s",t[j]);
  35. strtolower(t[j]);
  36. }
  37.  
  38.  
  39.  
  40.  
  41. for (j=0;j<=n-1;j++)
  42. {
  43. k=0;
  44. strcpy(v,t[j]);
  45. for (i=j+1;i<=n-1;i++)
  46. {
  47. if (strcmp (t[i],v)<0)
  48. {
  49. strcpy(v,t[i]);
  50. k=i;
  51. }
  52. }
  53. if (k>0)
  54. {
  55. strcpy (s,t[j]);
  56. strcpy (t[j],v);
  57. strcpy (t[k],s);
  58. }
  59. }
  60.  
  61.  
  62.  
  63.  
  64. for (j=0;j<=n-1;j++)
  65. {
  66. printf ("%s ",t[j]);
  67. }
  68. printf ("\n");
  69. }
  70. return 0;
  71. }
Success #stdin #stdout 0.02s 2204KB
stdin
Standard input is empty
stdout
Standard output is empty