题解 | #动态字符串#

动态字符串

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

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String str = scanner.next();

        //write your code here......
        String res;
        int len = str.length();
        int index = len % 3;
        res = str.substring(0, index);

        while (index + 3 <= len){
            res = res + "," + str.substring(index, index+3);
            index += 3;
        }
        System.out.println(res);

    }
}

全部评论

相关推荐

点赞 评论 收藏
分享
07-10 14:08
已编辑
江西农业大学 Java
念旧select:做完把项目放到自己硬盘里给他看,看完拷走
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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