zoukankan      html  css  js  c++  java
  • 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
    **********************************************************************/
  • 相关阅读:
    ASP.NET 实现邮件发送和接受的功能(Sockets)
    使用Sql server进行分布式查询
    Sqlserver中的一些技巧
    使用sql server中的全文索引
    水晶报表的装载和修改文本
    创建作业的通用存储过程
    MS SQL数据库备份和恢复
    数据库运用XML操作
    安装程序自动安装数据库
    ASP.NET 实现邮件发送和接受的功能(Mail)
  • 原文地址:https://www.cnblogs.com/jkzr/p/10163602.html
Copyright © 2011-2022 走看看