X-man

导航

hdu 1002 java 大数相加

package Main;
//import java.io.InputStream;
import java.math.BigDecimal;
import java.util.Scanner;
public class Main {
    public static void main(String[] args)
    {
        int _case;
        BigDecimal a,b;
        a=new BigDecimal("0");
        b=new BigDecimal("0");
        Scanner reader=new Scanner(System.in);
        _case=reader.nextInt();
        int js=0;
        while(_case-->0)
        {
            js++;
            a=reader.nextBigDecimal();
            b=reader.nextBigDecimal();
            System.out.println("Case "+js+":");//.stripTrailingZeros().toPlainString()科学计数法转字符串
            System.out.println(a+" + "+b+" = "+a.add(b));
            if(_case>0)System.out.println();
        }
    }
}

 

posted on 2013-12-06 22:08  雨钝风轻  阅读(224)  评论(0编辑  收藏  举报