//字符串中找最大数字
class Untitled {
public static void main(String[] args) {
String str = "abc123de4567ff";
char[] cs = str.toCharArray();
int count = 0;
int max = 0;
int end = 0;
for(int i = 0; i < cs.length; i++){
if(Character.isDigit(cs[i])){
count++;
}
else{
if(count > max){
max = count;
end = i;
}
count = 0;
}
}
String s1 = str.substring(end-max, end);
System.out.println(s1);
}
}
class Untitled {
public static void main(String[] args) {
String str = "abc123de4567ff";
char[] cs = str.toCharArray();
int count = 0;
int max = 0;
int end = 0;
for(int i = 0; i < cs.length; i++){
if(Character.isDigit(cs[i])){
count++;
}
else{
if(count > max){
max = count;
end = i;
}
count = 0;
}
}
String s1 = str.substring(end-max, end);
System.out.println(s1);
}
}
全部评论
相关推荐
点赞 评论 收藏
分享
02-07 10:52
复旦大学 Java
混子不想混:非常能理解,感觉他们就靠着入行早,打压新人一样。我这个公司也是,天天干的累死累活,然后绩效打C,合着让新人被绩效,像是年底攒棺材本一样。总是打击之后,还会让人开始自我怀疑,是不是我努力的还不够,实际上并不是,就是他们不做人,故意打压新人。 点赞 评论 收藏
分享

