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 |
为什么会runtime wrong 自己机子上运行的好好的我的程序是: 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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator