fork(2) download
  1. #include <iomanip>
  2. #include <iostream>
  3. #include<algorithm>
  4. #include <math.h>
  5. #include<assert.h>
  6. #include<cmath>
  7. #include<string>
  8. #include<string.h>
  9. #include <vector>
  10. using namespace std;
  11. int main()
  12. {
  13. std::ios_base::sync_with_stdio(0);
  14. cin.tie(NULL);
  15. cout.tie(0);
  16. int raw1 = 0;
  17. int col1 = 0;
  18. int raw2 = 0;
  19. int col2 = 0;
  20. cin >> raw1 >> col1;
  21. vector <vector<int>>arr1(raw1,vector<int>(col1));
  22.  
  23.  
  24.  
  25. for (int i = 0; i <raw1; i++)
  26. {
  27. for (int j = 0; j < col1; j++)
  28. {
  29. cin>>arr1[i][j];
  30. }
  31. }
  32. cin >> raw2 >> col2;
  33. vector<vector<int>>arr2(raw2, vector<int >(col2));
  34. vector<vector<int>>arr3(col1, vector<int>(raw2));
  35. for (int i = 0; i < raw2; i++)
  36. {
  37. for (int j = 0; j < col2; j++)
  38. {
  39. cin>> arr2[i][j];
  40. }
  41. }
  42. for (int i = 0; i < raw1; i++)
  43. {
  44.  
  45. for (int j = 0; j < col2; j++)
  46. {
  47. arr3[i][j]=0;
  48. for (int k = 0; k < col1; k++)
  49. arr3[i][j] += arr1[i][k] * arr2[k][j];
  50.  
  51. }
  52.  
  53. }
  54. for (int i = 0; i < raw1; i++)
  55. {
  56. for (int j = 0; j < col2; j++)
  57. {
  58. cout << arr3[i][j] << " ";
  59. }
  60. cout << "\n";
  61. }
  62.  
  63. return 0;
  64. }
  65.  
Success #stdin #stdout 0s 4432KB
stdin
Standard input is empty
stdout
Standard output is empty