Sicily 3712. Matrix multiplication

来源:互联网 发布:施乐2011设置网络打印 编辑:程序博客网 时间:2024/06/08 08:32
#include<iostream>using namespace std;int max1[1001][1001];int max2[1002][1001];int sum[1001][1001];int main(){    int n;    while(cin >> n){    for(int i=0; i < n; i++)        for(int j=0; j < n; j++)            cin >> max1[i][j];    for(int i=0; i < n; i++)        for(int j=0; j < n; j++)            cin >> max2[i][j];    for(int i=0; i < n; i++)        for(int j=0; j < n; j++)            for(int f=0; f < n; f++){                sum[i][j]+=max1[i][f]*max2[f][j];                }    for(int i=0; i < n; i++)        for(int j=0; j < n; j++)            if(j<n-1)cout << sum[i][j] <<" ";            else cout << sum[i][j] <<endl;    for(int i=0; i < n; i++)        for(int j=0; j < n; j++)            sum[i][j]=0;     }    return 0;}                                 

0 0
原创粉丝点击