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=;
int n;
string s;
int main()
{
scanf("%d",&n);
while(n--)
{
cin>>s;
int len=s.length();
if(s[len-]=='x'||s[len-]=='s'||s[len-]=='o'||(s[len-]=='h'&&s[len-]=='c'))
{
cout<<s<<"es"<<endl;
}
else if(s[len-]=='y')
{
for(int i=;i<len-;i++)
cout<<s[i];
cout<<"ies"<<endl;
}
else if(s[len-]=='f')
{
for(int i=;i<len-;i++)
cout<<s[i];
cout<<"ves"<<endl;
}
else if((s[len-]=='e'&&s[len-]=='f'))
{
for(int i=;i<len-;i++)
cout<<s[i];
cout<<"ves"<<endl;
}
else
cout<<s<<"s"<<endl;
}
return ;
} /**********************************************************************
Problem: 2216
User: therang
Language: C++
Result: AC
Time:420 ms
Memory:2024 kb
**********************************************************************/
CSU 2018年12月月赛 D 2216 : Words Transformation的更多相关文章
- CSU 2018年12月月赛 B 2214: Sequence Magic
Description 有一个1到N的自然数序列1,2,3,...,N-1,N. 我们对它进行M次操作,每次操作将其中连续的一段区间 [Ai,Bi][Ai,Bi] (即第Ai个元素到第Bi个元素之间的 ...
- CSU 2018年12月月赛 H(2220): Godsend
Description Leha somehow found an array consisting of n integers. Looking at it, he came up with a t ...
- CSU 2018年12月月赛 G(2219): Coin
Description 有这样一个众所周知的问题: 你面前有7个硬币,其中有一个劣质的(它比正常的硬币轻一点点),你有一个天平,问需要你需要使用天平多少次能保证找到那个劣质的硬币. 众所周知的算法是: ...
- CSU 2018年12月月赛 F(2218): Finding prime numbers
Description xrdog has a number set. There are 95 numbers in this set. They all have something in com ...
- CSU 2018年12月月赛 A 2213: Physics Exam
Description 高中物理老师总认为给学生文本形式的问题比给纯计算形式的问题要求更高.毕竟,学生首先得阅读和理解问题. 因此,他们描述一个问题不像”U=10V,I=5A,P=?”,而是”有一个含 ...
- 2018年12月8日广州.NET微软技术俱乐部活动总结
吕毅写了一篇活动总结,写得很好!原文地址是:https://blog.walterlv.com/post/december-event-microsoft-technology-salon.html ...
- [2018-11-27]2018年12月1日宁波dotnet社区线下活动
离上次活动,转眼又过了一个月,幸得各路大神支持,于本周六(12月1日),宁波dotnet社区的线下分享活动又来啦! 活动嘉宾及主题 董斌辉 2015-2019年微软全球最有价值专家(.NET方向) 2 ...
- CodePlus2017 12月月赛 div2可做题2
11月的月赛错过了,来打12月月赛,由于很(zi)想(ji)拿(tai)衣(ruo)服(la),所以去打div2. T1是一个sb模拟,但是机房全卡死在这道语文题上了,基本上弄了一个半小时,T2可以秒 ...
- web前端开发2018年12月找工作总结
2018年的冬天额外的冷,由内致外... 作为一名刚刚踏入社会的实习生,可谓是狠狠的体验了一把什么叫社会(同时也感叹父母赚钱真的很不容易) 前几天看见这样一句话"如果你不知道社会的辛苦,要么 ...
随机推荐
- mysql 联合2个列的数据 然后呈现出来
SELECT a.voyageNum,CONCAT(a.startDate,'~',a.endDate) AS 日期 FROM tchw_voyageoilcost a ,tchw_voyageoi ...
- maven中添加json-lib的jar包
在maven配置文件pom.xml中添加如下配置信息: <dependency> <groupId>net.sf.json-lib</groupId> <ar ...
- Vue解决安卓4.4不兼容的问题
1.npm安装 npm install babel-polyfillnpm install es6-promise package.json中会出现 "babel-polyfill" ...
- mybatis 基础详解
转 https://www.cnblogs.com/Mr-Kenson/p/8124680.html mybatis 是一个开源的 用于对数据库操作的框架, 读者基本都大体了解其基本功能, 我就不多解 ...
- [CF1076G] Array Game
Description Transmission Gate Solution 考虑Dp,设Dp[i] 表示当我们从前面跳跃到i时,他是必胜还是必败. 那么\(Dp[i] = Min(Dp[j], !( ...
- Jumping Jack CodeForces - 11B
Jumping Jack CodeForces - 11B 就是一个贪心. 基本思路: 正负没有关系,先取绝对值. 首先跳过头,然后考虑怎么回来. 设超过头的步数为kk.如果kk为偶数,那么直接在前面 ...
- zoj 3649 lca与倍增dp
参考:http://www.xuebuyuan.com/609502.html 先说题意: 给出一幅图,求最大生成树,并在这棵树上进行查询操作:给出两个结点编号x和y,求从x到y的路径上,由每个结点的 ...
- Android Dialogs(5)[正常显示dlg,将Fragment显示为dialog,将Aty显示为dlg,嵌入],关闭Dialog
Showing a Dialog When you want to show your dialog, create an instance of your DialogFragment and ca ...
- Android插件开发
插件开发的概念: 对于一个功能特别多,代码量特别大的App比如支付宝.360手机助手来说,如果把所有的功能和代码都写在一个App中,就会造成App体积过于庞大,用户下载体验差,不方便测试,业务.模块耦 ...
- SQL Case 语句的使用
-----简单case 使用 select 学号,姓名, case 专业 when '金融系' then '1' when '材料成型及控制工程' then '2' else '3' end from ...