Preface I caught a cold this weekend and never wrote a program. I got a question and practiced it. It is strange that this question can only be used as a global array. Passing parameters will always cause problems and gdb has not been debugged, this is too strange. Question [html] Description: implement a calculator to output the value of a + B. Input: the input includes two numbers a and B. The number of digits a and B cannot exceed 1000. Output: multiple groups of test data may exist. For each group of data, the value of a + B is output. Sample input: 2 6 10000000000000000000 10000000000000000000000000000000 sample output: 8 10000000000010000000000000000000 ac code [cpp] # include <stdio. h> # include <stdlib. h> # include <string. h> # define MAX 1002 char a [MAX], B [MAX], sum [MAX]; void bigDataPlus (); int main () {while (scanf ("% s", a, B )! = EOF) {bigDataPlus (); printf ("% s \ n", sum);} return 0;} void bigDataPlus () {int I, j, k, c, len_a, len_ B; // initialize memset (sum, 0, sizeof (sum); len_a = strlen (a); len_ B = strlen (B ); // carry ID c = 0; for (I = len_a-1, j = len_ B-1, k = 0; I> = 0 & j> = 0; I --, j --, k ++) {sum [k] = a [I] + B [j] + c-'0'; if (sum [k]> '9 ') {c = 1; sum [k]-= 10;} else {c = 0 ;}// a> B while (I> = 0) {sum [k] = a [I] + c; if (sum [k]> '9') {sum [k]-= 10; c = 1 ;} else {c = 0;} k ++; I --;} // B> a while (j> = 0) {sum [k] = B [j] + c; if (sum [k]> '9') {sum [k]-= 10; c = 1;} else {c = 0;} k ++; j --;} // if (c = 1) {sum [k ++] = '1';} // flip char temp; for (I = 0, j = k-1; I <j; I ++, j --) {temp = sum [I]; sum [I] = sum [j]; sum [j] = temp ;}} /*************************************** * *********************** Problem: 1198 User: wangzhengyi Language: C Result: Accepted Time: 30 MS Memory: 912 kb ************************************** **************************/