2011Andy @ 2023-02-23 13:22:04
#include <bits/stdc++.h>
using namespace std;
string a , b;
int A[2010] , B[2010] , c[2010] , jinwei;
int main(){
cin >> a >> b;
for(int i = 0 , j = a.size() - 1 ; i < a.size() ; i++ , j--) A[j] = a[i] - '0';
for(int i = 0 , j = b.size() - 1 ; i < b.size() ; i++ , j--) B[j] = b[i] - '0';
for(int i = 0 ; i < max(a.size() , b.size()) ; i++){
if(c[i] > 9){
jinwei = 0;
for( ; ; ){
if(A[i] * B[i] <= 9) break;
jinwei++;
A[i] /= 2;
}
}
c[i] += A[i] * B[i];
}
for(int i = max(a.size() , b.size()) - 1 ; i >= 0 ; --i){
cout << c[i];
}
return 0;
}
by __Tonycyt__ @ 2023-02-23 13:33:24
在cout的for前面加一个
int chu=a.length()+b.length();
while(c[chu]==0 && chu>1) chu--;
by ___njr___ @ 2023-02-23 13:45:03
。。。
by 2011Andy @ 2023-02-23 13:48:14
0