fork download
  1. #include <stdio.h>
  2. #include <string.h>
  3. int isConsonant(char ch)
  4. {
  5. int f = 1;
  6. if(ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u'){
  7. f = 0;
  8. }
  9. else{
  10. f = 1;
  11. }
  12. return f;
  13. }
  14. int comp(char s1[], char s2[])
  15. {
  16. int f = 0, i, l1 = 0, l2 = 0;
  17. l1 = strlen(s1);
  18. l2 = strlen(s2);
  19. if(l1 == l2){
  20. for(i = 0; i < l1; i++){
  21. if(s1[i] != s2[i]){
  22. f = 0;
  23. break;
  24. }
  25. else{
  26. f = 1;
  27. }
  28. }
  29. }
  30. return f;
  31. }
  32. int main()
  33. {
  34. int l, n, i, j, k, len, m, f, p, f1, l1;
  35. char irr[105][205], tmp1[105], tmp2[105], instr[105];
  36. scanf("%d %d", &l, &n);
  37. getchar();
  38. for(i = 0; i < l; i++){
  39. gets(irr[i]);
  40. }
  41. for(i = 0; i < n; i++){
  42. gets(instr);
  43. f1 = 1;
  44. for(j = 0; j < l; j++){
  45. len = 0;
  46. for(p = 0; irr[j][p] != '\0'; p++){
  47. len++;
  48. }
  49. m = 0;
  50. f = 0;
  51. f1 = 1;
  52. for(k = 0; k <= len; k++){
  53. if(irr[j][k] != ' ' && f == 0){
  54. tmp1[m++] = irr[j][k];
  55. }
  56. else if(irr[j][k] != '\0' && f == 1){
  57. tmp2[m++] = irr[j][k];
  58. }
  59. else if(irr[j][k] == ' '){
  60. tmp1[m++] = '\0';
  61. m = 0;
  62. f = 1;
  63. }
  64. else if(irr[j][k] == '\0'){
  65. tmp2[m] = '\0';
  66. f = 0;
  67. }
  68. }
  69. if(comp(tmp1, instr) == 1){
  70. printf("%s\n", tmp2);
  71. f1 = 0;
  72. break;
  73. }
  74. }
  75. if(f1 == 1){
  76. l1 = strlen(instr);
  77. if((isConsonant(instr[l1-2]) == 1) && (instr[l1-1] == 'y')){
  78. for(i = 0; i < l1-1; i++){
  79. printf("%c", instr[i]);
  80. }
  81. printf("ies\n");
  82. }
  83. else if(instr[l1-1] == 'o' || instr[l1-1] == 's' || instr[l1-1] == 'x'){
  84. printf("%s", instr);
  85. printf("es\n");
  86. }
  87. else if((instr[l1-2] == 'c' || instr[l1-2] == 's') && instr[l1-1] == 'h'){
  88. printf("%s", instr);
  89. printf("es\n");
  90. }
  91. else{
  92. printf("%s", instr);
  93. printf("s\n");
  94. }
  95. }
  96. }
  97. return 0;
  98. }
Success #stdin #stdout 0s 3344KB
stdin
3 20
rice rice
spaghetti spaghetti
octopus octopi
rice
lobster
spaghetti
strawberry
octopus
peach
turkey
boy
buy
bay
grey
biy
too
vex
brash
nexus
chaste
park
label
snake
stdout
rice
lobsters
spaghetti
strawberries
octopi
peaches
turkeys
boys
buys
bays
greys
biys
tooes
vexes