一、题目链接
http://noi.openjudge.cn/ch0107/28/
二、解题思路
三、实施步骤
四、Java程序
import java.util.Scanner;
public class Main {
public String reverseSentence(String text) {
String[] words = text.split(" ");
int n = words.length;
StringBuilder ans = new StringBuilder();
ans.append(words[n - 1]);
for (int i = n - 2; i >= 0; i--) {
ans.append(" ").append(words[i]);
}
return ans.toString();
}
public static void main(String[] args) {
Main test = new Main();
Scanner input = new Scanner(System.in);
String text = input.nextLine();
System.out.print(test.reverseSentence(text));
}
}