A + B Problem II(大数加法)
题目链接:A + B Problem II
问题描述
Problem Description
I have a very simple problem for you. Given two integers A and B, your job is to calculate the Sum of A + B.
Input
The first line of the input contains an integer T(1<=T<=20) which means the number of test cases. Then T lines follow, each line consists of two positive integers, A and B. Notice that the integers are very large, that means you should not process them by using 32-bit integer. You may assume the length of each integer will not exceed 1000.
Output
For each test case, you should output two lines. The first line is “Case #:”, # means the number of the test case. The second line is the an equation “A + B = Sum”, Sum means the result of A + B. Note there are some spaces int the equation. Output a blank line between two test cases.
Sample Input
2
1 2
112233445566778899 998877665544332211
Sample Output
Case 1:
1 + 2 = 3
Case 2:
112233445566778899 + 998877665544332211 = 1111111111111111110
题目大意
给定数字a、b,计算a+b的和。例如,给定a=112233445566778899,b=998877665544332211,则和为1111111111111111110。
解题思路
由于数据过大,无法使用long long存储数据,因此使用char类型数组来储存数据,逐位进行计算
代码
#include <stdio.h>
#include <string.h>
#include <iostream>
char s1[1000], s2[1000];
int a[1000], b[1000], c[1000];
using namespace std;
int

最低0.47元/天 解锁文章
615

被折叠的 条评论
为什么被折叠?



