HWOJ句子逆序

import java.util.*;
import java.lang.*;
public class Main{
public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String str = sc.nextLine();
        int len = str.length();
        String[] res = str.split(" ");
        StringBuffer sb = new StringBuffer();
        for(int i=res.length-1;i>=0;i--){
            sb.append(res[i]+" ");
        }
        System.out.println(sb.substring(0,len));
        sc.close();
    }
}

你可能感兴趣的:(HWOJ句子逆序)