import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Main { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String s; while ((s=br.readLine())!=null){ String[] str=s.split(" "); for (int i = 0; i < str[0].length(); i++) { System.out.print(str[0].charAt(i)); } for (int i = 0; i < str[1].length(); i++) { System.out.print(str[1].charAt(i)); } System.out.println(); } } }
import java.util.Scanner; import java.util.ArrayList; public class Main{ public static void main(String[] args){ char[] ch = new Scanner(System.in).nextLine().toCharArray(); ArrayList al = new ArrayList(); for(int i=0;i<ch.length;i++){ if(' ' != ch[i]){ al.add(ch[i]); } } for(int i=0;i<al.size();i++){ System.out.print(al.get(i)); } } }
运行时间:32ms
占用内存:10812k
import java.util.Scanner;
/**
* @author Allen_Hua
* @create_time 创建时间:May 12, 2018 9:12:50 PM 类说明
*/
public class Main {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
while (scan.hasNext()) {
String str = scan.nextLine();
System.out.println(str.replaceAll(" ", ""));
}
}
}