1095 名词复数形式
经验值:0 时间限制:1000毫秒
题目描述 Description
在英语中,单数名词变为复数形式会有很多种不同的情况,比如直接加-s,-es,变y为i再加-es……现只考虑以下3种情况:
1.凡是以s、z、x、ch、sh结尾的词,在该词末尾加上后辍es构成复数;
2、以y结尾的名词,将y改变为i,再加es;
3、除以上情况以外的都直接加s。
给定一个单词,请输出其复数形式。
输入描述 Input Description
输入为一行,包含一个字符串,为一个单数名词(长度不超过15)。
输出描述 Output Description
输出为一行,包含一个字符串,为该单词的复数形式。
样例输入 Sample Input
fox
样例输出 Sample Output
foxes
#include<iostream>
#include<fstream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<string>
#include<iomanip>
#include<cstdlib>
#include<vector>
using namespace std;
char s[30],d[]= "s",e[]= "es";
int main(){
gets(s);
int len=strlen(s);
if((s[len-1]=='o'||s[len-1]=='s'||s[len-1]=='x')||((s[len-2]=='c'||s[len-2]=='s')&&(s[len-1]=='h')))
strcat(s,e);
else if(s[len-1]=='y'){
s[len-1]='i',strcat(s,e);
}
else{
strcat(s,d);
}
puts(s);
return 0;
}
WA90
为什么???
武建豪在2021-06-08 22:25:48追加了内容
ding
武建豪在2021-06-14 22:56:41追加了内容
ding
#include<bits/stdc++.h>
using namespace std;
string str;
int post;
int main(){
cin>>str;
post=str.size()-1;
if(str[post]=='s'||str[post]=='z'||str[post]=='x'||str[post]=='h'&&str[post-1]=='c'||str[post]=='h'&&str[post-1]=='s'){
cout<<str+"es";
return 0;
}
if(str[post]=='y'){
str[post]='i';
cout<<str+"es";
return 0;
}
else{
cout<<str+"s";
return 0;
}
return 0;
}