本人c++新手,最近在自学高精度乘法,求大神指点我的代码错在哪,万分感谢
程序代码:
#include <iostream> #include <cstring> using namespace std; int main() { int t; cin >> t; for(int z = 0;z < t;z++) { int c[205] = {0}; int i,j,len; string m,n; cin >> m >> n; memset(c,0,sizeof(c)); for(i = 1;i <= m.length();i++) for(j = 1;j <= n.length();j++) c[i+j-1] = c[i+j-1]+(m[i]-48)*(n[j]-48); len = m.length()+n.length(); for(i = 1;i < len;i++) { c[i+1] = c[i+1]+c[i]/10; c[i] = c[i]%10; } while(c[len] == 0) { len--; } for(i = len;i >= 1;i--) { cout << c[i]; } cout << endl; } }