Problem B: 去掉空格
Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 405 Solved: 236
Description
读入一些字符串,将其中的空格去掉。
Input
输入为多行,每行为一个字符串,字符串只由字母、数字和空格组成,长度不超过80。请处理到文件末尾。
Output
对于每行输入,输出转换后的字符串。
Sample Input
Hello World1 2 3Nice to meet youabc
Sample Output
HelloWorld123Nicetomeetyouabc
public class Main {
public static void main(String[] args) {
Scanner cin = new Scanner(System.in);
while (cin.hasNext()) {
String str = cin.nextLine();
System.out.println(str.replaceAll(" ", ""));
}
}
}