文字関数
数字=index (○、△) はじめ
数字=length(○)
文字列=substr(ing)(○、△、□) ○で△から□長さ
○、△=文字列
1、長さ length L=length(文字),
2、うしろ二つ(Lの値6), new=substr(文字,L-1,2),
3、検索 if(new= ="ch"){answer=文字 "es" }
4、print "こたえ" answer
word=$0
0、 語尾が s, sh, ch, x, o の時は es
をつけます。 【例】 watch → watches
語尾が 〈 子音字+y 〉 の時は y を i に変えて es
をつけます。 【例】 study → studies 〔studyの語尾は〈
d+y 〉です〕
*母音字・・・
a, i, u, e, o *子音字・・・
母音字以外の文字
* play
の語尾は 〈 a+y
〉なのでこの規則に当てはまりません。参照URL http://www.nsr1.com/kotsu.html
Ex=[1]"ch"
Ex=[2]"sh"
Ex=[3]"x"
BEGIN{
n_ex=5 ;
ex[1] = 'ch' ;
ex[2] = 'sh' ;
ex[3] = 'x' ;
ex[4] = 'o' ;
ex[5] = 's' ;
}
################
word = $0 ;
l = length (word) ;
new = substr(word,l-1,2) ;
#####
if (new==ex[1]){
answer = word "es" ;
}
else answer = word "s" ;
#############
END{
print "答え"= answer ;