theindependencethout 2017-02-08 23:14:13
点我顶贴
收藏
删除
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main()
{char a1[100],b1[100];
gets(a1);
gets(b1);
int a[100],b[100];
int sum=0,lena,lenb;
lena=strlen(a1);
lenb=strlen(b1);
for (int i=0;i<=lena-1;i++)
a[lena-i]=a1[i]-48;
for (int i=0;i<=lenb-1;i++)
b[lenb-i]=b1[i]-48;
for (int i=lenb;i>0;i--)
for (int j=lena;j>0;j--)
{sum=sum+b[i]*a[j];
}
cout<<sum;
}
#1 Dream86333@2021-11-25 03:25:59
34832
回复
删除
#include<iostream>
using namespace std;
const int m=10000;
int main()
{
int a[m],b[m],k1=1,k2=1;
long long x,y,sum=0;
cin>>x>>y;
while(x>0)
{
a[k1]=x%10;
x/=10;
k1++;
}
while(y>0)
{
b[k2]=y%10;
y/=10;
k2++;
}
for(int i=1;i<=k1;i++)
{
for(int j=1;j<=k2;j++)
{
sum+=a[i]*b[j];
}
}
cout<<sum;
return 0;
}