题解 | #明明的随机数#
句子逆序
http://www.nowcoder.com/practice/48b3cb4e3c694d9da5526e6255bb73c3
利用栈先进后出的特性
import java.util.Scanner;
import java.util.Stack;
public class HJ13_juzinixu {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
String input = sc.nextLine();
String[] strings = input.split(" ");
Stack<String> stack = new Stack<>();
for (String c: strings) {
stack.push(c);
}
while (!stack.empty()){
System.out.print(stack.pop()+" ");
}
}
}