I am trying to implement the multiplication of string numbers with Stobics. The input is two numbers written in string. Then I translate them into an array and then try to multiply. Already analyzed the algorithm several times and can not find the error. Help to understand, please.
#include "stdafx.h" #include <string> #include <iostream> #include <climits> using namespace std; int main() { string a, n; int* A, *B, *C, length, l, cc; //cin>>a; //cin>>n; a = "1"; n = "1"; A = new int [a.size()]; B = new int [n.size()]; for (int i = 0; i < a.size(); i++) A[i] = a[a.size() - i - 1] - '0'; for (int i = 0; i < n.size(); i++) B[i] = n[n.size() - i - 1] - '0'; length = a.size() + n.size() + 1 ; l = length; C = new int [length]; for (int ix = 0; ix < a.size() - 1; ix++) for (int jx = 0; jx < n.size() - 1; jx++) { C[ix + jx - 1] += A[ix] * B[jx]; cc == A[ix] * B[jx]; } for (int ix = 0; ix < length; ix++) { C[ix + 1] += C[ix] / 10; C[ix] %= 10; } while (C[length] == 0) length-- ; for (int i = l - 1; i > -1; i--) cout << C[i]; system("PAUSE"); }