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可以

posted @ 2018-12-09 12:46  MichaelCecil  阅读(1923)  评论(0编辑  收藏  举报