Problem H: 零起點學演算法109——單數變複數
阿新 • • 發佈:2018-12-09
#include <stdio.h> #include<string.h> int main(void) { int n; char word[100]; scanf("%d",&n); getchar(); int i; while(n!=0) { gets(word); int k=strlen(word); if(word[k-1]=='y') strcat(word,"es"); else if(word[k-2]=='s'||word[k-1]=='x') strcat(word,"es"); else if(word[k-2]=='s'&&word[k-1]=='h') strcat(word,"es"); else if(word[k-2]=='c'&&word[k-1]=='h') strcat(word,"es"); else if(word[k-1]=='o') strcat(word,"es"); elsestrcat(word,"s"); puts(word); n--; } return 0; }
似乎用printf提交ac不了,用put可以