CSU 2018年12月月赛 D 2216 : Words Transformation

Description

There are n words, you have to turn them into plural form.

If a singular noun ends with ch, x, s, o, then the plural is -es. For example, witch -> witches, tomato -> tomatoes.

If a singular noun ends with f or fe, then the plural is -ves. For example, leaf -> leaves, knife -> knives. Note that f becomes v.

The noun ending with y will become -ies. For example, family -> families.

All other singular nouns are added with s. For example, book -> books.

Input

The first line, a number n, represents the number of words.

Next n lines, each line represents a word.

The number of words <= 10000, 1 <= word length <= 100.

Output

N lines.

Output the words in plural form.

Sample Input

3
contest
hero
lady

Sample Output

contests
heroes
ladies

题意:模拟题,水题,注意f,fe这块就行了。
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <math.h>
#include <set>
using namespace std;
const int maxn=10005;
int n;
string s;
int main()
{
    scanf("%d",&n);
    while(n--)
    {
        cin>>s;
        int len=s.length();
        if(s[len-1]=='x'||s[len-1]=='s'||s[len-1]=='o'||(s[len-1]=='h'&&s[len-2]=='c'))
        {
            cout<<s<<"es"<<endl;
        }
        else if(s[len-1]=='y')
        {
            for(int i=0;i<len-1;i++)
                cout<<s[i];
            cout<<"ies"<<endl;
        }
        else if(s[len-1]=='f')
        {
            for(int i=0;i<len-1;i++)
                cout<<s[i];
            cout<<"ves"<<endl;
        }
        else if((s[len-1]=='e'&&s[len-2]=='f'))
        {
            for(int i=0;i<len-2;i++)
                cout<<s[i];
            cout<<"ves"<<endl;
        }
        else
            cout<<s<<"s"<<endl;
    }
    return 0;
}

/**********************************************************************
    Problem: 2216
    User: therang
    Language: C++
    Result: AC
    Time:420 ms
    Memory:2024 kb
**********************************************************************/

 

转载于:https://www.cnblogs.com/jkzr/p/10163602.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值