Title Description
Description
Give two positive integers a and B to calculate the value of the a+b. Ensure that the number of digits A and B does not exceed 500 digits.
Enter a description input
Description
Read in two positive integers separated by a space
outputs description output
Description
The value of the output a+b
sample input to
sample
3 12
Sample output Sample
outputs
15
data
size & Hint
The number of digits of two positive integers is less than 500 bits
Simple thinking
#include <stdio.h> #include <string.h>int main () {char a[505], B[505],c[505],d[505];int sum[505];memset ( Sum, 0, sizeof (sum));/*gets_s (c); gets_s (d); */SCANF ("%s%s", C, d); int I, J, tmp, T = 0;for (i = strlen (c)-1, j = 0; I ; = 0; I--, j + +) A[j] = c[i];a[j] = ' + '; for (i = strlen (d)-1, j = 0; I >= 0; I--, j + +) B[j] = d[i];b[j] = ' n '; for (i = 0; a[ I]! = ' &&b[i]! = ' \ n '; i++) {tmp = a[i]-' 0 ' + b[i]-' 0 ' + t;t = tmp/10;sum[i] = tmp% 10;} while (a[i]! = 0) {tmp = a[i]-' 0 ' + t;t = tmp/10;sum[i++] = tmp% 10;} while (b[i]! = 0) {tmp = b[i]-' 0 ' + t;t = tmp/10;sum[i++] = tmp% 10;} for (i = 501; sum[i] = = 0; i--) and while (I >= 0) printf ("%d", sum[i--]);p UTS (""); return 0;}
The addition of high precision