题解 | #单词倒排#

单词倒排

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

import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
        char[] arr = s.toCharArray();
        for (int i = 0; i < arr.length; i++){
            if (arr[i] < 'A' || (arr[i] > 'Z' && arr[i] < 'a') || arr[i] > 'z'){
                arr[i] = ' ';
            }
        }
        String s1 = new String(arr);
        String[] arr1 = s1.trim().split(" ");
        for (int i = arr1.length - 1; i >= 0; i--){
            System.out.print(arr1[i] + " ");
        }
    }
}

全部评论

相关推荐

晗江雪:其实我只是觉得你们导员说的很好笑
点赞 评论 收藏
分享
废物一个0offer:认真的吗二本本科找人工智能岗位
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

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