题解 | #句子逆序# 紧扣题目
句子逆序
https://www.nowcoder.com/practice/48b3cb4e3c694d9da5526e6255bb73c3
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while(sc.hasNext()) {
String line = sc.nextLine();
if (line.length()>1001){
line = line.substring(0, 1001);
}
String[] lineArr = line.split(" ");
for(int i=lineArr.length-1;i>-1;i--){
System.out.print(lineArr[i]+ " ");
}
}
}
}
#华为笔试##句子逆序#
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while(sc.hasNext()) {
String line = sc.nextLine();
if (line.length()>1001){
line = line.substring(0, 1001);
}
String[] lineArr = line.split(" ");
for(int i=lineArr.length-1;i>-1;i--){
System.out.print(lineArr[i]+ " ");
}
}
}
}
#华为笔试##句子逆序#