#include <iostream>
using namespace std;
int main()
{
int a[100],b[100],c[100][100];
int i,j;
int x,y;
cin>>x>>y;
char e[105];
for(i=0;i<x;i++) {cin>>e[i];a[i]=e[i]-48;}
for(i=0;i<y;i++) {cin>>e[i];b[i]=e[i]-48;}
for(i=0;i<y;i++)
{
for(j=0;j<=x+y;j++)
c[i][j]=0;
}
for(i=0;i<y;i++)
{
int n=x+y-i;
int z=0;
for(j=0;j<x;j++)
{
c[i][n]=(a[x-1-j]*b[y-1-i])%10+z;
int r=a[x-1-j]*b[y-1-i];
if(r>9) z=r/10;
else z=0;
n=n-1;
}
c[i][n]=z;
}
for(i=0;i<y;i++)
{
for(j=0;j<=x+y;j++)
cout<<c[i][j]<<' ';
cout<<endl;
}
int d[105];int z=0;
for(i=x+y;i>=0;i--)
{
d[i]=0;
d[i]=z;
for(j=y-1;j>=0;j--)
{
d[i]=d[i]+c[j][i];
}
if(d[i]>9)
{
z=d[i]/10;
d[i]=d[i]%10;
}
else z=0;
}
cout<<endl;
if(d[0]==0)i=1;
else i=0;
for(i=0;i<=x+y;i++)
cout<<d[i]<<' ';
cout<<endl;
return 0;
using namespace std;
int main()
{
int a[100],b[100],c[100][100];
int i,j;
int x,y;
cin>>x>>y;
char e[105];
for(i=0;i<x;i++) {cin>>e[i];a[i]=e[i]-48;}
for(i=0;i<y;i++) {cin>>e[i];b[i]=e[i]-48;}
for(i=0;i<y;i++)
{
for(j=0;j<=x+y;j++)
c[i][j]=0;
}
for(i=0;i<y;i++)
{
int n=x+y-i;
int z=0;
for(j=0;j<x;j++)
{
c[i][n]=(a[x-1-j]*b[y-1-i])%10+z;
int r=a[x-1-j]*b[y-1-i];
if(r>9) z=r/10;
else z=0;
n=n-1;
}
c[i][n]=z;
}
for(i=0;i<y;i++)
{
for(j=0;j<=x+y;j++)
cout<<c[i][j]<<' ';
cout<<endl;
}
int d[105];int z=0;
for(i=x+y;i>=0;i--)
{
d[i]=0;
d[i]=z;
for(j=y-1;j>=0;j--)
{
d[i]=d[i]+c[j][i];
}
if(d[i]>9)
{
z=d[i]/10;
d[i]=d[i]%10;
}
else z=0;
}
cout<<endl;
if(d[0]==0)i=1;
else i=0;
for(i=0;i<=x+y;i++)
cout<<d[i]<<' ';
cout<<endl;
return 0;
}
意会吧- -