当前位置:网站首页>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
边栏推荐
- 2020-12-04
- ArcGIS application (20) the ArcGIS grid image symbol system prompts "this dataset does not have valid histogram required for classificati..."
- C sqlsugar, hisql, FreeSQL ORM framework all-round performance test vs. sqlserver performance test
- Which securities company is the safest and best choice for stock trading account opening
- Business stability construction ideas based on Cloud Architecture
- Tianyi cloud takes advantage of the new infrastructure to build a "4+2" capability system for digital transformation
- flink同步mysql数据到ES
- 2021-01-29
- 2021-04-05
- 口令安全是什么意思?等保2.0政策中口令安全标准条款有哪些?
猜你喜欢

Common operations of sourcetree version management

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

2021-04-14

数据库访问工具简介

SourceTree版本管理常用操作

2021-04-14

C sqlsugar, hisql, FreeSQL ORM framework all-round performance test vs. sqlserver performance test

three.js模拟驾驶游览艺术展厅---打造超级相机控制器

2021-05-02

程序员接私活兼职选择
随机推荐
1. class inheritance (point)
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
好东西要分享啦
2021-01-29
2020-12-20
Tianyi cloud takes advantage of the new infrastructure to build a "4+2" capability system for digital transformation
Unity:利用 射线Ray 检测物体
Redis缓存
[STM32 skill] use the hardware I2C of STM32 Hal library to drive rx8025t real-time clock chip
2020-12-20
os.Args[1:]中命令行参数为空时,不执行内部语句
Spark SQL 访问json和jdbc数据源
js防止PC端复制正确的链接
输出字符串中最长的单词
口令安全是什么意思?等保2.0政策中口令安全标准条款有哪些?
Stop using system Currenttimemillis() takes too long to count. It's too low. Stopwatch is easy to use!
Spark SQL Generic Load/Save Functions(2.4.3)
2. interface (calculator)
同步电路与跨时钟域电路设计2——多bit信号的跨时钟域传输(FIFO)
为 localStorage 添加过期时间