哎呀 我也做了这一题,也是通过不了 public static void main(String[] args) { Scanner sc = new Scanner(System.in); while (sc.hasNext()) { String str = sc.nextLine(); int count = 0; char c,c1; for (int i = 0; i <str.length() ; i++) { c = str.charAt(i); if(i!=str.length()-1){ c1 = str.charAt(i+1); }else { c1 = c; } if(c!=c1){ count++; } } System.out.println(count); } }
点赞 1

相关推荐

不愿透露姓名的神秘牛友
10-04 05:12
kalistar:简历留六个字,北京大学(本科),黑体加粗,看看哪个hr不长眼敢碰瓷我们北大✌
点赞 评论 收藏
分享
牛客网
牛客网在线编程
牛客网题解
牛客企业服务