CSU 2018年12月月赛 D 2216 : Words Transformation
2024-09-05 16:42:17
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
**********************************************************************/
最新文章
- CentOS如何查看硬盘品牌型号等具体信息
- [LeetCode]444. Sequence Reconstruction
- jqzoom与scrollpic配合的问题
- php的memcache和memcached扩展区别
- Json数据与Json数据转换
- String之“==”与equals
- MySQL functions, IF, CASE
- Python基础:函数
- 系统启动时,spring配置文件解析失败,报”cvc-elt.1: 找不到元素 &#39;beans&#39; 的声明“异常
- poj 3635(bfs+优先队列)
- BitSet
- ZOJ 3430 Detect the Virus 【AC自动机+解码】
- android ellipsize 属性详解
- 解决ios双击页面上移问题
- Android图片裁剪之自由裁剪
- AlphaBlend參数BLENDFUNCTION
- 用Linux命令行实现删除和复制指定类型的文件
- 【WebService】WebService学习笔记
- poptest老李谈分布式与集群 2
- UrlRewriter配置IIS支持伪静态
热门文章
- Orchard 相关
- 洛谷 P3952 时间复杂度【模拟】
- poj 3243 Clever Y &;&; 1467: Pku3243 clever Y【扩展BSGS】
- bzoj 1180: [CROATIAN2009]OTOCI【LCT】
- 【原创】《从0开始学Elasticsearch》—集群健康和索引管理
- hdu 1044 Collect More Jewels
- 题解报告:poj 2533 Longest Ordered Subsequence(最长上升子序列LIS)
- 题解报告:poj 3320 Jessica&#39;s Reading Problem(尺取法)
- IOS利用Core Text对文字进行排版 - 转
- [转]强制取消TFS2008中其它成员的签出文件