题目:倒置字符串
方法一
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
while (in.hasNextLine()) {// 注意,如果输入是多个测试用例,请通过while循环处理多个测试用例
String str = in.nextLine();
String[] s = str.split(" ");
StringBuilder sb = new StringBuilder();
for (int i = 0; i < s.length; i++) {
sb.append(s[s.length - i - 1] + " ");
}
System.out.println(sb.toString());
}
}
}