交错01串

交错01串

http://www.nowcoder.com/questionTerminal/3fbd8fe929ea4eb3a254c0ed34ac993a

import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String str = sc.nextLine();
        char[] ch = str.toCharArray();
        int a = 1; int temp = 1;
        for (int i=0;i<ch.length-1;i++){
            if(ch[i]!= ch[i+1]){
                a++;
            }else {
                if(temp<=a){
                    temp = a;
                    a=1;
                }
            }
        }
        System.out.println(temp>a?temp:a);
    }
}
全部评论

相关推荐

不亏是提前批,神仙打架,鼠鼠不配了
站队站对牛:现在92都报工艺岗了
投递韶音科技等公司7个岗位
点赞 评论 收藏
分享
不愿透露姓名的神秘牛友
07-08 14:08
点赞 评论 收藏
分享
05-20 13:59
门头沟学院 Java
米黑子米黑子:你这个成绩不争取下保研?
点赞 评论 收藏
分享
不愿透露姓名的神秘牛友
07-08 12:10
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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