-
Notifications
You must be signed in to change notification settings - Fork 12
/
1050.cpp
53 lines (49 loc) · 1.07 KB
/
1050.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
using namespace std;
int const maxSize=105;
int A[maxSize][maxSize];
int B[maxSize][maxSize];
int C[maxSize][maxSize];
int main()
{
int T,n;
scanf("%d",&T);
while(T--)
{
scanf("%d",&n);
for(int i=0;i<n;i++)
for(int j=0;j<n;j++)
{
scanf("%d",&A[i][j]);
}
for(int i=0;i<n;i++)
for(int j=0;j<n;j++)
{
scanf("%d",&B[i][j]);
}
for(int i=0;i<n;i++)
for(int j=0;j<n;j++)
{
C[i][j]=0;
for(int k=0;k<n;k++)
{
C[i][j]+=A[i][k]*B[k][j];
}
}
for(int i=0;i<n;i++)
{
for(int j=0;j<n;j++)
{
if(j!=0)
printf(" %d",C[i][j]);
else
printf("%d",C[i][j]);
}
printf("\n");
}
}
return 0;
}//Parsed in 0.108 seconds