返回列表 發帖
  1. #inclue<bits/stdc++.h>
  2. using namespace std;
  3. int a1,b1,a2,b2;
  4. int main()
  5. {
  6.     cin>>a1>>b1;
  7.     int arr1[a1][b1];
  8.     for(int i=0;i<a2;i++)
  9.         for(int j=0;j<=b2;j++)
  10.             cin>>arr2[i][j];
  11.     if(b1!=a2)
  12.     {
  13.         cout<<"error"endl;
  14.     }else
  15.     {
  16.         for(int i=0;i<a1;i++)
  17.         {
  18.             for(int j=0;j<b2;j++)
  19.             {
  20.                 int sum=0;
  21.                 for(int k=0;k<b1;k++)
  22.                     sum+arr1[i][k]*arr2[k][j];
  23.                 if(j!=0)
  24.                     cout<<" ";
  25.                 cout<<sum;
  26.             }
  27.             cout<endl;
  28.         }
  29.     }
  30.     return 0;
  31. }
複製代碼

TOP

返回列表