//连中次数
public
static int LzNum(String str) { // 分割成数组 char[] c = str.toCharArray(); // 定义一个记住最大次数的变量 int max = 0; // 循环比较 for (int i = 0; i < c.length; i++) { // 定义一个中间值 int is = 1;// 以为是两两比较所以中间会上一次,就像断木头一样,你想想哈 for (int j = i; j < c.length - 1; j++) { if (c[j] == c[j + 1] && c[j] == '1') { is++; } else { break; } if (is > max) { max = is; } } } return max; }

 

posted on 2018-08-14 16:01  十七年蝉  阅读(368)  评论(0编辑  收藏  举报