题解 | 多组_带空格的字符串_T组形式

多组_带空格的字符串_T组形式

https://www.nowcoder.com/practice/cff28a28d7f54419a640a8bb19f4275f

import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc   = new Scanner(System.in);
        int t  = sc.nextInt();
        sc.nextLine();
        for(int i = 0;i<t;i++){
            int n  = sc.nextInt();
            sc.nextLine();
            String s  = sc.nextLine();
            String result  = reverseString(s);
            System.out.println(result);
        }
        sc.close();
    }
    public static String reverseString(String s){
        String nospace = s.replaceAll(" ","");
        StringBuilder sb  = new StringBuilder(nospace);
        return sb.reverse().toString();
    }
}

全部评论

相关推荐

投递长鑫存储等公司8个岗位
点赞 评论 收藏
分享
点赞 评论 收藏
分享
那一天的Java_J...:他本来公司就是做这个的,不就是正常的游戏客户端和服务器开发,软硬件联动,有啥恶心不恶心的,提前告诉你就是怕你接受不了,接受不了就没必要再往后走流程浪费时间,虽然这公司是一坨。
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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