全是水题
版本1
#include
#include
#include
using namespace std;
char a[15],b[15];
int ans;
int main(){
while(~scanf("%s %s",a,b)){
ans = 0;
for(int i = 0; a[i] != 0; ++i)
for(int j = 0; b[j] != 0; ++j)
ans += (a[i]-'0')*(b[j]-'0');
printf("%d\n",ans);
}
return 0;
}
版本2
#include
#include
using namespace std;
int arr[15],brr[15],size1,size2;
int main(){
int a,b,ans;
while(~scanf("%d %d",&a,&b)){
size1 = 0;
size2 = 0;
ans = 0;
while(a){
arr[size1++] = a%10;a/=10;
}
while(b){
brr[size2++] = b%10;b/=10;
}
for(int i = 0; i < size1; ++i)
for(int j = 0; j < size2; ++j)
ans += arr[i]*brr[j];
printf("%d\n",ans);
}
return 0;
}