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代码哪里错了 谁能帮忙看下

Posted by javatest123 at 2008-07-23 12:29:54 on Problem 1001
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) throws Exception{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		String str;
		while((str=br.readLine())!=null){
			String[] t=str.split(" ");		
			String[] a=new String[2];
			for(int i=0,k=0;i<t.length;i++)
				if(!t[i].equals(""))
					a[k++]=t[i];
			BigDecimal b=new BigDecimal(a[0]);
			BigDecimal res=new BigDecimal(a[0]);
			int e=Integer.parseInt(a[1]);
			while((--e)>0){
				res=res.multiply(b);
			}
			String strRes=res.toPlainString();
			while((strRes.endsWith("0")&&strRes.contains("."))||strRes.endsWith("."))
				strRes=strRes.substring(0,strRes.length()-1);
			System.out.println(strRes);
		}
	}
}

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