题解 | #句子逆序#
句子逆序
https://www.nowcoder.com/practice/48b3cb4e3c694d9da5526e6255bb73c3
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String str=" ";
while(str.isEmpty()||str.equals(" ")||sc.hasNext()){
str=sc.nextLine();//next() 不会读取字符前/后的空格/Tab键
String[] strs=str.split(" ");
int l=strs.length;
for (int i = l-1; i >=0 ; i--) {
System.out.print(strs[i]+" ");
}
}
}
}
