20: delete the word suffix, 20 Word Suffix
20: Delete the Word Suffix
- View
- Submit
- Statistics
- Question
-
Total time limit:
-
1000 ms
-
Memory limit:
-
65536kB
-
Description
-
If a word is given and ends with an er, ly, or ing suffix, the suffix is deleted (the word length after the suffix is not 0). Otherwise, no operation is performed.
-
Input
-
Enter a line containing a word (there is no space in the middle of the word, and the maximum length of each word is 32 ).
-
Output
-
Output the words that have been processed according to the question requirements.
-
Sample Input
-
referer
-
Sample output
-
refer
#include<iostream>#include<cstdio>#include<cstring>using namespace std;char a[100001];char ans[100001];int now=0;int main(){ gets(a); int l=strlen(a); if(a[l-2]=='e'&&a[l-1]=='r') { for(int i=0;i<l-2;i++) cout<<a[i]; } else if(a[l-2]=='l'&&a[l-1]=='y') { for(int i=0;i<l-2;i++) cout<<a[i]; } else if(a[l-3]=='i'&&a[l-2]=='n'&&a[l-1]=='g') { for(int i=0;i<l-3;i++) cout<<a[i]; } else puts(a); return 0;}