fork download
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <stdlib.h>
  4.  
  5. int main() {
  6.  
  7. char word[1000], s[] = "s", ch[] = "ch", x[] = "x", o[] = "o", sh[] = "sh", a[] = "a", i[] = "i", u[] = "u", e[] = "e", copy[100], y[] = "y", f[] = "f", fe[] = "fe";
  8. int num, n, j, cpy = 0;
  9.  
  10. scanf("%d", &n);
  11. for (j = 0; j < n; j++) {
  12. scanf("%s", &word);
  13. num = strlen(word);
  14. if (!strcmp(&word[num - 1], &s[0])) {
  15. printf("%ses\n", word);
  16. }
  17. else
  18. if (!strcmp(&word[num - 1], &x[0])) {
  19. printf("%ses\n", word);
  20. }
  21. else
  22. if (!strcmp(&word[num - 1], &o[0])) {
  23. printf("%ses\n", word);
  24. }
  25. else
  26. if (strcmp(&word[num - 1], &sh[1]) == 0 && strcmp(&word[num - 2], &sh[0])) {
  27. printf("%ses\n", word);
  28. }
  29. else
  30. if (strcmp(&word[num - 1], &ch[1]) == 0 && strcmp(&word[num - 2], &ch[0])) {
  31. printf("%ses\n", word);
  32. }
  33. else
  34. if (strcmp(&word[num - 1], &y[0]) == 0 && strcmp(&word[num - 2], &a[0]) == 1 && strcmp(&word[num - 2], &i[0]) == 1 && strcmp(&word[num - 2], &u[0]) == 1 && strcmp(&word[num - 2], &e[0]) == 1 && strcmp(&word[num - 2], &o[0]) == 1) {
  35. cpy = num - 1;
  36. strncpy(copy, word, cpy);
  37. copy[cpy] = '\0';
  38. printf("%sies\n", copy);
  39. }
  40. else
  41. if (!strcmp(&word[num - 1], &f[0])) {
  42. cpy = num - 1;
  43. strncpy(copy, word, cpy);
  44. copy[cpy] = '\0';
  45. printf("%sves\n", copy);
  46. }
  47. else if (strcmp(&word[num - 2], &fe[0]) == 0 && strcmp(&word[num - 1], &fe[1]) == 0) {
  48. cpy = num - 2;
  49. strncpy(copy, word, cpy);
  50. copy[cpy] = '\0';
  51. printf("%sves\n", copy);
  52. }
  53. else {
  54.  
  55.  
  56. printf("%ss\n", word);
  57. }
  58. }
  59. return 0;
  60. }
Success #stdin #stdout 0s 10320KB
stdin
7
box
photo
axis
dish
church
leaf
knife
stdout
boxes
photoes
axises
dishes
churches
leaves
knives