当前位置:网站首页>OJ daily practice - filter extra spaces
OJ daily practice - filter extra spaces
2022-06-22 23:33:00 【KJ. JK】
Problem description :
There may be multiple consecutive spaces in a sentence , Filter out the extra space , Just leave a space .
Input
a line , A string ( Length not exceeding 200), There are no spaces at the beginning and the end of a sentence .
Output
Filtered sentences .

Java Code :
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner in=new Scanner(System.in);
String a=in.nextLine();
String b=a.replaceAll("\\s+"," ");
String c[]=b.split(" ");
for(int i=0;i<c.length;i++) {
System.out.print(c[i]+" ");
}
}
}
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
边栏推荐
- ArcGIS应用(二十)Arcgis 栅格图像符号系统提示“This dataset does not have valid histogram required for classificati…”
- OJ每日一练——病毒的增生
- Freshman girls' nonsense programming is popular! Those who understand programming are tied with Q after reading
- Spark SQL accessing JSON and JDBC data sources
- 优化——线性规划
- Unity:利用 射线Ray 检测物体
- 一个spark app demo
- 斐波那契数列合集
- canvas生成海报
- Stop using system Currenttimemillis() takes too long to count. It's too low. Stopwatch is easy to use!
猜你喜欢
![[kubernetes series] overview of kubernetes](/img/c2/b42f7a0db236558cc466a508d3d579.png)
[kubernetes series] overview of kubernetes

OJ每日一练——跨越2020

MySQL master-slave synchronization and its basic process of database and table division

Smart data won two annual awards at the second isig China Industrial Intelligence Conference

企业数字化不是各自发展,而是全面SaaS化推进

2021-04-16

优化——线性规划

10 Super VIM plug-ins, I can't put them down

2021-08-22

程序员接私活兼职选择
随机推荐
Reddit's discussion on lamda model: it is not stateless. It adopts a dual process. Compared with the way it edits Wikipedia, it doesn't matter whether it has feelings or not
js----SVG转PNG
three.js模拟驾驶游览艺术展厅---打造超级相机控制器
Array and string offset access syntax with curly braces is no longer support
[arm] it is reported that horizontal display is set for LVDS screen of rk3568 development board
异步FIFO
获取鼠标移动的方向
启牛app下载证券开户,是安全的吗?有风险嘛?
2021-08-21
Dip1000,1 of D
Leakcanary source code (2)
Tp5.1 upload excel file and read its contents
使用Redisson操作分布式队列的注意事项
What does password security mean? What are the password security standard clauses in the ISO 2.0 policy?
斐波那契数列合集
阻止别人使用浏览器调试
Spark SQL Start(2.4.3)
swagger2 使用方法
2020-12-20
Use full function simulation design method