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 |
那位帮忙检查一下那里错了啊,,感激不尽!!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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator