题解 | #句子逆序#
句子逆序
http://www.nowcoder.com/practice/48b3cb4e3c694d9da5526e6255bb73c3
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); String str = scanner.nextLine(); String[] value = str.split(" "); int n = value.length - 1; for (int j = (n - 1) >> 1; j >= 0; j--) { int k = n - j; String cj = value[j]; String ck = value[k]; value[j] = ck; value[k] = cj; } System.out.println(String.join(" ", value)); } }