fork download
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. int main() {
  5. char s[1000], w[100], h[1000] = "";
  6. int i, j, k, len;
  7.  
  8. fgets(s, sizeof(s), stdin);
  9. s[strcspn(s, "\n")] = 0;
  10.  
  11. len = strlen(s);
  12. i = 0;
  13.  
  14. while (i < len) {
  15. j = 0;
  16. while (i < len && s[i] != ' ') {
  17. w[j++] = s[i++];
  18. }
  19. w[j] = '\0';
  20.  
  21. char r[100] = "";
  22. for (k = j - 1; k >= 0; k--) {
  23. if (k > 0 && w[k - 1] == 'n' && w[k] == 'g') {
  24. strcat(r, "ng");
  25. k--;
  26. } else {
  27. char t[2];
  28. if (w[k] >= 'A' && w[k] <= 'Z') w[k] += 32;
  29. t[0] = w[k];
  30. t[1] = '\0';
  31. strcat(r, t);
  32. }
  33. }
  34.  
  35. if (strlen(h) > 0) strcat(h, " ");
  36. strcat(h, r);
  37.  
  38. while (i < len && s[i] == ' ') i++;
  39. }
  40.  
  41. if (h[0] >= 'a' && h[0] <= 'z') h[0] -= 32;
  42.  
  43. printf("%s\n", h);
  44. return 0;
  45. }
  46.  
Success #stdin #stdout 0s 5300KB
stdin
Saya orang malang
stdout
Ayas ngaro ngalam