【codevs1287】矩阵乘法(矩阵乘法)

          题目描述

          传送门

          题解

          矩阵乘法(暴力)。

          代码

          #include<iostream>
          #include<cstring>
          #include<cstdio>
          using namespace std;
          
          const int max_n=205;
          const int max_m=205;
          
          int n1,m1,n2,m2;
          int a[max_n][max_m],b[max_n][max_m],c[max_n][max_m];
          
          int main(){
              scanf("%d%d",&n1,&m1);
              for (int i=1;i<=n1;++i)
                for (int j=1;j<=m1;++j)
                  scanf("%d",&a[i][j]);
              scanf("%d%d",&n2,&m2);
              for (int i=1;i<=n2;++i)
                for (int j=1;j<=m2;++j)
                  scanf("%d",&b[i][j]);
              for (int i=1;i<=n1;++i)
                for (int j=1;j<=m2;++j)
                  for (int k=1;k<=n2;++k)
                    c[i][j]+=a[i][k]*b[k][j];
              for (int i=1;i<=n1;++i)
                for (int j=1;j<=m2;++j)
                  printf("%d%c",c[i][j]," \n"[j==m2]);
          }
          相关文章
          相关标签/搜索
          三十码期期必中√资料今晚六给彩开奖结果,白小姐中特玄机,六开彩开奖现场直播,2017开奖记录开奖结果,开马现场直播,马报免费资料2017大全