[编程题]句子逆序
句子逆序
http://www.nowcoder.com/questionTerminal/48b3cb4e3c694d9da5526e6255bb73c3
import java.util.Scanner;
public class Main14 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while (sc.hasNext()) {
String s = sc.nextLine();
String[] split = s.split(" ");
StringBuilder sb = new StringBuilder();
for (int i = split.length-1; i >= 0; i--) {
if (i == 0) {
sb.append(split[i]);
} else {
sb.append(split+" ");
}
}
System.out.println(sb.toString());
}
}
}