码迷,mamicode.com
首页 > 编程语言 > 详细

Java大数加法 HDU1002

时间:2015-08-04 20:52:21      阅读:148      评论:0      收藏:0      [点我收藏+]

标签:

技术分享
 1 import java.math.*;
 2 import java.util.Scanner;
 3 
 4 
 5 public class Main{
 6     public static void main(String[] args){
 7         BigInteger a,b;
 8         int n;
 9         BigInteger ans;
10         Scanner cin = new Scanner(System.in);
11         n=cin.nextInt();
12         a=cin.nextBigInteger();
13         b=cin.nextBigInteger();
14         ans=a.add(b);
15         System.out.println("Case 1:");
16         System.out.println(a+" + "+b+" = "+ans);
17         for(int i=2;i<=n;i++)
18         {
19             a=cin.nextBigInteger();
20             b=cin.nextBigInteger();
21             ans=a.add(b);
22             System.out.println();
23             System.out.println("Case "+i+":");
24             System.out.println(a+" + "+b+" = "+ans);
25         }
26     }
27 }
View Code

 

Java大数加法 HDU1002

标签:

原文地址:http://www.cnblogs.com/wsruning/p/4702996.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!