代码如下:
import java.util.Scanner; public class Main { public static void main(String[] args) { // TODO Auto-generated method stub Scanner input = new Scanner(System.in); String str = input.nextLine(); String[] strArr = str.split(" "); for(int i=0;i<strArr.length;i++){ if(i==(strArr.length-1)){ System.out.print(strArr[strArr.length-i-1]); }else{ System.out.print(strArr[strArr.length-i-1]+" "); } } } }