#include<iostream>
using namespace std;
//fun1 传入一个两个数组数组 将结果返回
int ** fun(int **a,int **b,int count)
{
int **c,temp=0;
c = new int*[30];
for(int i = 0;i < count;i++)
{
c[i] = new int[30];
for(int j = 0;j<count;j++)
{
for(int k = 0;k < count;k++)
{
temp += a[k][i]*b[j][k];
}
c[i][j] = temp;
}
}
return c;
}
int main()
{
int **b;
int **a;
a = new int*[30];
b = new int*[30];
for(int i = 0;i<30;i++)
{
a[i] = new int[30];
b[i] = new int[30];
}
int floor,count;
cin >> floor>>count;
for(int i= 0;i < floor;i++)
{
for(int j = 0;j < floor;j++)
{
cin >> a[i][j];
b[i][j] = a[i][j];
}
}
while(--count)
{
a = fun(a,b,floor);
}
for(int i=0;i<floor;i++)
{
for(int j = 0;j < floor;j++)
{
cout << a[i][j]<<" ";
}
cout << endl;
}
}
网友评论