#include<iostream>
using namespace std;
int Input(int a[][100],int b[][100])
{
int i,j,n;
cout<<"Please input the columnsize:"<<endl;
cin>>n;
cout<<"Please input the first matrix which the size is "<<n <<"* "<<n<<":"<<endl;
for(i=0;i<n;i++)
for(j=0;j<n;j++)
cin>>a[i][j];
cout<<"Please input the second matrix which the size is "<<n <<"* "<<n<<":"<<endl;
for(i=0;i<n;i++)
for(j=0;j<n;j++)
cin>>b[i][j];
return n;
}
int addMatrix(int a[][100],int b[][100],int c[][100],int n)
{
int i,j;
for(i=0;i<n;i++)
for(j=0;j<n;j++)
c[i][j]=a[i][j]+b[i][j];
return 0;
}
int multiplyMatrix(int a[][100],int b[][100],int d[][100],int n)
{
int i,j,k;
for(i=0;i<n;i++)
for(k=0;k<n;k++)
{
d[i][k]=0;
for(j=0;j<n;j++)
d[i][k]+=a[i][j]*b[j][k];
}
return 0;
}
int Outputa(int c[][100],int n)
{
int i,j;
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
cout<<c[i][j]<<" ";
cout<<endl;
}
return 0;
}
int Outputm(int d[][100],int n)
{
int i,j;
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
cout<<d[i][j]<<" ";
cout<<endl;
}
return 0;
}
int main()
{
int a[100][100];
int b[100][100];
int c[100][100];
int d[100][100];
int n;
n=Input(a,b);
addMatrix(a,b,c,n);
multiplyMatrix(a,b,d,n);
Outputa(c,n);
Outputm(d,n);
return 0;
}