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

那位帮忙检查一下那里错了啊,,感激不尽!!

Posted by vivian90214 at 2008-12-12 12:14:01 on Problem 1001
package acm;
import java.util.*;
import java.math.*;

public class Main 
{
	public static void main(String args[])
	{
		int i,tag;
		Scanner cin=new Scanner(System.in);
		BigDecimal a=cin.nextBigDecimal();
		BigDecimal c= BigDecimal.ONE;
		int b=cin.nextInt();
		tag=0;
		for(i=0;i<b;i++)
			c=c.multiply(a);
		String temp=c.toPlainString();
		for(i=0;i<temp.length()-1;i++)
			if(temp.charAt(i)=='.')
			{
				tag=1;
				break;
			}
		if(tag==1)
		{
			for(i=temp.length()-1;i>=0;)
			{
				if(temp.charAt(i)=='0')
					i--;
				else
					break;
				if(temp.charAt(i)=='.')
				{
				    i--;
					break;
				}
			}
		}
		if(temp.charAt(0)!='0')
			System.out.println(temp.substring(0,i+1));
		else 
			System.out.println(temp.substring(1,i+1));
	}
}

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