题解 | #单词倒排#
单词倒排
http://www.nowcoder.com/practice/81544a4989df4109b33c2d65037c5836
import java.util.*;
public class Main{
public static void main(String[] args){
Scanner s = new Scanner(System.in);
String line =s.nextLine();
char[] chars =line.toCharArray();
for (int i =0;i<chars.length;i++){
char c = chars[i];
if (c>'z' || c<'A' || (c>'Z' && c<'a')){
chars[i]=' ';
}
}
line=new String(chars);
String[] arr = line.split(" ");
for(int i =arr.length-1;i>=0;i--){
System.out.print(arr[i]+" ");
}
System.out.println();
}
}