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

为什么会runtime wrong 自己机子上运行的好好的

Posted by flourish at 2005-02-21 16:41:42 on Problem 1519
我的程序是:

import java.io.*;
class Main {
         public static void main(String[] args)throws IOException{
          	BufferedReader stdin=new BufferedReader(new InputStreamReader(
         			System.in));
         	int[] data=new int[1024];
         	for(int i=0;;i++){
         		if((data[i]=Integer.parseInt(stdin.readLine()))==0)
         			break;
         	}
         	for(int i=0;;i++){
         		if(data[i]==0)
         			break;
         		else
         			System.out.println(getRoot(data[i]));         				
         		}
         	}
         public static int getRoot(int number){
         	int sum=0;
         	if(number<10)
         		sum+=number;
         	else{
         		sum+=number%10;
         		sum+=getRoot(number/10);
         	}
         	while(sum>10)
         		sum=getRoot(sum);
         	return sum;
         }
}
大虾帮忙看看

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