// plural(n,s) // // 用法:为字符串加s变为复数,当n的取值不是+/-1时,就在s后添加后缀"s";当n的取值是+/-1时,就在s后不加后缀"s" //n为1,不加s . disp plural(1,"banana") banana //n为2,加s . disp plural(2,"banana") bananas //n为2,加s . disp plural(2,"horse") horses //n为-1,不加s . disp plural(-1,"horse") horse //n为0,不是1或-1,加s . disp plural(0,"horse") horses //n为0,不是1或-1,加s . disp plural(0,"horsx") horsxs . // plural(n,s1,s2) //用法: // 可以给s1添加删减后缀。当n的取值不为+/-1时,以s2指定的形式修正("+"或"-")或替代。 //如果s2前有"+",表示将s2加到s1后;如果s2前为"-",则返回s1中去掉s2 字符串后剩下的字符串;如果s2前既没有"+"也没有"-",则plural(n,s1,s2)=s2。 //n为2,+s2,连接hot+pot=hotpot . disp plural(2,"hot","+pot") hotpot ////n为2,-s2,连接bookpot-pot=book . disp plural(2,"bookpot","-pot") book ////n为2,s2,结果为s2) . disp plural(2,"book","pot") pot //n为1,结果为s1 . disp plural(1,"hot","+pot") hot //n为1,结果为s1 . disp plural(1,"bookpot","-pot") bookpot //n为1,结果为s1 . disp plural(1,"book","pot") book
标签:disp,s2,s1,book,plural,pot From: https://www.cnblogs.com/xkdn/p/17189662.html