上机题目(初级)-大数求和
发布时间:2021-03-18 21:33:32  所属栏目:大数据  来源:网络整理 
            导读:描述:? 给定两个非常大的正整数A和B,位数在50至100之间。求C=A+B; ? 题目类别: ?字符串? 难度: ?中级? 运行时间限制: 10Sec 内存限制: 128MByte 阶段: ?入职前练习? 输入: ? 因为A和B很大,从高位到低位,以字符串的形式输入两行数字A和B。A和B的位数在50
                
                
                
            | 
                         
 代码如下: import java.io.*;
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner cin = new Scanner(new BufferedInputStream(System.in));
		String add1 = cin.nextLine();
		String add2 = cin.nextLine();
		java.math.BigInteger res1 = new java.math.BigInteger(add1);
		java.math.BigInteger res2 = new java.math.BigInteger(add2);
		java.math.BigInteger result = res1.add(res2);
		System.out.println(result);
	}
} 
**喜欢的朋友请关注我,另欢迎阅读我的电子书? (编辑:91站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!  | 
                  


