题解 | #单词倒排#
单词倒排
https://www.nowcoder.com/practice/81544a4989df4109b33c2d65037c5836
import java.util.*; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); String str = in.nextLine(); for(int i=0;i<str.length();i++){ if(!Character.isLetter(str.charAt(i))){ str=str.replace(String.valueOf(str.charAt(i))," "); } } String[] Arr = str.split(" "); for(int i=Arr.length-1;i>=0;i--){ System.out.print(Arr[i]+" "); } } }