题解 | #字符串中找出连续最长的数字串#

字符串中找出连续最长的数字串

http://www.nowcoder.com/practice/bd891093881d4ddf9e56e7cc8416562d

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
        String[] split = s.split("[^0-9]");
        String tmp = "";

        for (int i = 0; i < split.length; i++){
            if (tmp.length() < split[i].length()){
                tmp = split[i];
            }
        }
        System.out.println(tmp);
    }
}
全部评论
这个写法很简单啊
点赞 回复 分享
发布于 2023-08-13 14:30 江苏

相关推荐

06-18 13:28
已编辑
门头沟学院 Web前端
爱睡觉的冰箱哥:《给予你300的工资》,阴的没边了
点赞 评论 收藏
分享
06-05 19:46
已编辑
武汉大学 后端
点赞 评论 收藏
分享
评论
8
收藏
分享

创作者周榜

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