第一道ac import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); String str = in.next(); String s = maxS(str); System.out.println(s); System.out.println(s.length()); in.close(); } public static String maxS (String str) { char[] strC = str.toCharArray(); int count=0, result=0, flag=0; for(int i=0; i<strC.length; i++) { if(strC[i]>='0' && strC[i]<='9') { count++; } else { count = 0; } if(count >= result) { flag = i-count+1; result = count; } } String s = ""; if(result > 0) { for(int i=0; i<result; i++) { s += strC[flag+i]; } } return s; } }
点赞 评论
牛客网
牛客企业服务