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