How can I multiply really big numbers c++

前端 未结 9 1677
梦谈多话
梦谈多话 2021-01-18 10:09

I have the following code

      int i, a, z;
i = 2343243443;
a = 5464354324324324;
z = i * a;
cout << z << endl;

When these are

9条回答
  •  遥遥无期
    2021-01-18 10:53

    Use pan paper approach as we used in 2nd standard. Store two numbers in two different array in reverse order. And take ans array as size of (arr1.size + arr2.size).And also initilize ans array to zero.

    In your case arr1[10]={3,4,4,3,4,2,3,4,3,2}, arr2[15]={4,2,3,4,2,3,,4,5,3,4,5,3,4,6,4,5};

    for(int i=0;i

    Then ans array contain the result.Please print carefully ans array. it may contain leading zero.

提交回复
热议问题