Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
java写的…大牛们帮忙看看为什么是runtime error啊!!!!import java.util.*; import java.io.*; class Main{ public static void main(String[] args){ Scanner sc=new Scanner(new BufferedInputStream(System.in)); int count=0; int begin=sc.nextInt(); int end=sc.nextInt(); while(begin<=end){ String str=Integer.toBinaryString(begin);//把begin转换成一个二进制表示的字符串 char[] ch=str.toCharArray(); int count0=0,count1=0; for(int i=0;i<ch.length;i++){ if(ch[i]==48) count0++; else count1++; } if(count0>=count1) count++; begin++; } System.out.println(count); } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator