题解 | #求最大连续bit数#
求最大连续bit数
https://www.nowcoder.com/practice/4b1658fd8ffb4217bc3b7e85a38cfaf2
import java.util.*; public class Main { public static void main(String[] args) { Scanner fzhinput = new Scanner(System.in); int n = fzhinput.nextInt(); int num=0,max=0; String zfc = Integer.toString(n,2); for(int i=0;i<zfc.length();i++){ if(zfc.charAt(i)=='1'){ num++; } else{ num=0; } if(num>max){ max=num; } } System.out.println(max); } }