20.删除单词后缀
描述
给定一个单词,如果该单词以er、ly或者ing后缀结尾, 则删除该后缀(题目保证删除后缀后的单词长度不为0), 否则不进行任何操作。
referer样例输出
refer
#include <stdio.h>
#include <string.h>
#define N 32
char A[N];
int main()
{
int i,len=0,end;
scanf("%s",A);
len=strlen(A);
end=len-1;
if (A[len - 3] == 'i' && A[len - 2] == 'n' && A[len - 1] == 'g')
end = len - 4;
if (A[len - 2] == 'e' && A[len - 1] == 'r')
end = len - 3;
if (A[len - 2] == 'l' && A[len - 1] == 'y')
end = len - 3;
for (i = 0; i <= end; i++) printf("%c", A[i]);
printf("\n");
return 0;
}