题解 | #单词倒排# | 正则即可

单词倒排

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

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

public class Main {
    public static void main(String[] args) throws IOException{
        BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
        String tmp = null;
        while ((tmp=bf.readLine())!=null && !tmp.equals("")) {
            String otherReg = "[^(a-z|A-Z|\\s)]";
            tmp = tmp.replaceAll(otherReg, " ");
            String[] strArr = tmp.split("\\s+");
            for(int i=strArr.length-1;i>=0;i--){
                System.out.print(strArr[i]+" ");
            }
        }
        bf.close();
    }
}
全部评论

相关推荐

绝迹的星:前端和后端写两份简历, 如果想干全栈就直接写求职意向为全栈工程师
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务