1. 程式人生 > >Problem H: 零起點學演算法109——單數變複數

Problem H: 零起點學演算法109——單數變複數

#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"); else
strcat(word,"s"); puts(word); n--; } return 0; }

似乎用printf提交ac不了,用put可以