当前位置:网站首页>OJ daily practice - delete word suffixes
OJ daily practice - delete word suffixes
2022-06-22 23:33:00 【KJ. JK】
Problem description :
Given a word , If the word follows er、ly perhaps ing The suffix ends , Delete the suffix ( Make sure that the length of the word after deleting the suffix is not 0), Otherwise, no operation will be carried out .
Input
The input line , Contains a word ( There is no space between words , The maximum length of each word is 32).
Output
Output the word according to the question .
Examples
Input
clearly
Output
clear
Java Code :
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner in=new Scanner(System.in);
String a=in.next();
char a1[]=a.toCharArray();
int i=a1.length;
if(a1[i-1]=='y'&&a1[i-2]=='l'){
for(int j=0;j<a1.length-2;j++) {
System.out.print(a1[j]);
}
}
else if(a1[i-1]=='r'&&a1[i-2]=='e'){
for(int j=0;j<a1.length-2;j++) {
System.out.print(a1[j]);
}
}
else if(a1[i-1]=='g'&&a1[i-2]=='n'&&a1[i-3]=='i'){
for(int j=0;j<a1.length-3;j++) {
System.out.print(a1[j]);
}
}
else {
System.out.print(a);
}
}
}
author :KJ.JK
If the article is helpful to you , Welcome to praise or star, Your support is the greatest encouragement to the author , The shortcomings can be corrected in the comments section , Communication and learning
边栏推荐
- Digital data was invited to participate in Nantong enterprise digital transformation Seminar
- OJ每日一练——病毒的增生
- 2020-12-20
- 2021-04-14
- 2020-12-04
- 使用HBuilder X编辑器安装终端窗口插件未响应的解决方案
- Summary of transport layer knowledge points
- ArcGIS application (20) the ArcGIS grid image symbol system prompts "this dataset does not have valid histogram required for classificati..."
- DML:Data Manipulation Language 数据操纵语言
- Stop using system Currenttimemillis() takes too long to count. It's too low. Stopwatch is easy to use!
猜你喜欢

Asynchronous FIFO

2021-04-05

Stop using system Currenttimemillis() takes too long to count. It's too low. Stopwatch is easy to use!

Future alternatives to IPv4! Read the advantages, features and address types of IPv6

ArcGIS application (20) the ArcGIS grid image symbol system prompts "this dataset does not have valid histogram required for classificati..."

Spark RDD Programming Guide(2.4.3)

How to continuously improve performance| DX R & D mode

Install the typescript environment and enable vscode to automatically monitor the compiled TS file as a JS file

canvas生成海报

Enterprise digitalization is not a separate development, but a comprehensive SaaS promotion
随机推荐
安装typescript环境并开启VSCode自动监视编译ts文件为js文件
2021-04-05
OJ每日一练——单词的长度
使用HBuilder X编辑器安装终端窗口插件未响应的解决方案
[kubernetes series] overview of kubernetes
输出字符串中最长的单词
Uniapp modifies array properties, and the view is not updated
How to change the dial on the apple Watch
2021-01-29
14. 最长公共前缀
SSH method 2 for adding node nodes in Jenkins
【ARM】讯为rk3568开发板lvds屏设置横屏显示
canvas生成海报
2021-03-06
2021-08-26
C language greedy snake
2020-12-20
2020-12-04
冒泡排序 指针
获取鼠标移动的方向