资源限制
时间限制:1.0s 内存限制:256.0MB
编写一个函数RegularPlural,其功能是实现一个英文单词的复数形式。复数的规则为:
(1) 如果单词末尾为s,x,z,ch或sh,则在后面加es
(2) 如果单词末尾为y,且前一个字母为辅音(除a, e, i, o, u以外的其它情况),则把y改成ies。
(3) 如果是其它情形,一律在后面加s。
编写测试程序,输入一个长度小于20的单词,输出该单词的复数形式。
输入:
box
输出:
boxes
word = list(input()) #把字符串转成列表
n = len(word)
if word[-1] == "s" or word[-1] == "x" or word[-1] == "z" or (word[-1] == "h" and (word[-2] == 'c' or word[-2] == 's')):
word.append('es')
elif word[-1] == "y" and word[-2] not in "aeiou":
word[-1] = "i"
word.append('es')
else:
word.append('s')
new_word = ''.join(word) #把列表转换成字符串
print(new_word)