题解 | #单词倒排#

单词倒排

http://www.nowcoder.com/practice/81544a4989df4109b33c2d65037c5836

import java.util.; import java.io.;

public class Main{ public static void main(String[] args){

    InputStreamReader reader = new InputStreamReader(System.in);
    try(BufferedReader br = new BufferedReader(reader)){

        String[] words = br.readLine().replaceAll("[^a-zA-Z]"," ").split(" ");
        final StringBuffer sb = new StringBuffer();
        for (int i = words.length - 1; i >= 0; i--) {

            sb.append(words[i]);
            if (i==0) continue;
            sb.append(" ");
        }

        System.out.println(sb);

    }catch (IOException e){
        System.out.println(e.getMessage());
    }


}

}

全部评论

相关推荐

11-09 11:01
济南大学 Java
Java抽象带篮子:外卖项目真得美化一下,可以看看我的详细的外卖话术帖子
点赞 评论 收藏
分享
点赞 收藏 评论
分享
牛客网
牛客企业服务