题解 | #句子逆序#
句子逆序
https://www.nowcoder.com/practice/48b3cb4e3c694d9da5526e6255bb73c3
import java.util.*; public class Main { public static void main(String[] args) { Scanner fzhinput = new Scanner(System.in); String engSentence; int i; StringBuilder stack= new StringBuilder(); while(fzhinput.hasNextLine()){ engSentence = fzhinput.nextLine(); String [] words = engSentence.split(" "); for(i=words.length-1;i>=0;i--){ stack.append(words[i]); stack.append(" "); } } System.out.println(stack); } }