题目:
A + B Problem II
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 167825 Accepted Submission(s): 32125
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
太久没有写高精度,今天写了一下高精度加法,第一次写高精度的时候用了80+行,后来改到<40行,结果现在太久没有写,一写就是70+ = =,当然这次和以前写的有点不一样,以前写的就是纯粹地为了得到那个答案,这次写有一点像是做模板的性质(虽然感觉这模板不可恭维= =),这次写的是写在一个结构体里面,这样是为了在需要高精度的运算的时候可以更加方便的使用(只是自己感觉方便使用= =),而且我把一个大数定义成结构体,结构体里面除了大数加法的函数以外还有大数和大数的长度以及大数由低位到高位的写法,方便以后添加高精度剪发,乘法,除法。
上代码:
1 #include2 #include 3 #define MAX 1050 4 using namespace std; 5 6 typedef struct N 7 { 8 char num[MAX],anum[MAX]; 9 int len;10 void anti()11 {12 int i;13 for(i=0;i