现在的位置: 首页 > 综合 > 正文

HDOJ 1002

2013年04月17日 ⁄ 综合 ⁄ 共 490字 ⁄ 字号 评论关闭

 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1002

 

简单的大数加法

源代码:

 

import java.math.BigInteger;
import java.util.Scanner;


public class Main{


	public static void main(String[] args) {
		
		int t;
		Scanner scanner=new Scanner(System.in);
		
		t=scanner.nextInt();
		
		for (int i = 1; i <=t; i++) {
			
			String str1,str2;
			BigInteger A,B;
			str1=scanner.next();
			str2=scanner.next();
			A=new BigInteger(str1);
			B=new BigInteger(str2);
			
			System.out.println("Case "+i+":");
			System.out.print(A+" + " +B +" = " );
			System.out.println(A.add(B));
			
			if(i!=t){
				System.out.println();
			}
			
			
		}
		
		

	}

}

抱歉!评论已关闭.