求一个byte对应的二进制的数字的中的最大的连续数

package demo_0514;

import java.io.BufferedReader;

public class demo {

	public static void main(String[] args) {
		//功能求一个byte 对应的数字的对应的二进制的数字的中的1的最大的连续数,例如3的00000011
//		最大	连续的2个1
		
//	输出:无
		
		
//		输出返回:对应的二进制的1的最大连续数
		
		
	BufferedReader br=new BufferedReader(System.in);
	String line="";
	while((line=br.readline())!=null) {
		int n=Integer.parseInt(line);
		getOneNumber(n);
	}
		
	}

	private static void getOneNumber(int n) { 
		
		char[] chs=Integer.toBinaryString(n).toCharArray();
		int count;
		
		
		for(int i=0;icount) {
					count=j-i;
				}
				i=j;
			}
			
			System.out.println(count);
		}
		
	}

}

 

你可能感兴趣的:(【02.每天一个算法】)