Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

java写的…大牛们帮忙看看为什么是runtime error啊!!!!

Posted by sinceowa at 2010-04-28 13:39:47 on Problem 3252
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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator