High-precision addition to the third time study ... I understand the content.
1#include <cstdio>2#include <cstring>3#include <iostream>4 using namespacestd;5 #defineMaxLen 1106 intMain () {7 CharA1[maxlen],b1[maxlen];//the original Addend string entered8 intA[maxlen],b[maxlen],c[maxlen],lena,lenb,lenc,x;//storage of two addend, results, length and rounding of addend results9Memset (A,0,sizeof(a));Tenmemset (b,0,sizeof(b)); OneMemset (c,0,sizeof(c));//Initialize Ascanf"%s%s", A1,B1); -Lena =strlen (A1); -LenB = strlen (B1);//calculates the length of a two string the for(intI=0; I <= Lena-1; i++) -A[lena-i]=a1[i]-'0';//addend into a array - for(inti =0; I <= LenB-1; i++) -B[lenb-i]=b1[i]-'0';//Addend into the b array +Lenc =1; -x =0; + while(Lenc <= Lena | | lenc<=LenB) { AC[LENC] = A[lenc] + B[lenc] +x;//two numbers added atx = C[lenc]/Ten;//Calculate Rounding -C[LENC]%=Ten;//the number of standard reservations -Lenc++; - } -C[LENC] =x; - if(C[lenc] = =0) inlenc--;//handling the highest rounding - for(inti = Lenc; i>=1; i--) tocout << C[i];//Output Results +cout<<Endl; - return 0; the}
High accuracy algorithm (high accuracy algorithm)