题解 | #句子逆序#
句子逆序
https://www.nowcoder.com/practice/48b3cb4e3c694d9da5526e6255bb73c3
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Main { public static void main(String[] args) { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String str = null; String[] strs =null; try { if (((str=br.readLine())!=null)) { strs = str.split(" "); } } catch (IOException e) { e.printStackTrace(); } if (strs!=null){ for (int i = strs.length - 1; i >= 0; i--) { if (i == 0) { System.out.print(strs[i]); } else { System.out.print(strs[i] + " "); } } } } }