Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- main()
- {
- int i, j, k, l;
- cout << "First matrix size(row column):" << endl;
- cin >> i >> j;
- cout << "Second matrix size(row column):" << endl;
- cin >> k >> l;
- int a[i][j], b[k][l], c[j][l];
- if (j == k)
- {
- cout << "First array:" << endl;
- for (int n = 0; n < i; n++)
- {
- for (int m = 0; m < j; m++)
- {
- cin >> a[n][m];
- }
- }
- cout << "Second array:" << endl;
- for (int n = 0; n < k; n++)
- {
- for (int m = 0; m < l; m++)
- {
- cin >> b[m][n];
- }
- }
- for (int t = 0; t < i; t++)
- {
- for (int u = 0; u < l; u++)
- {
- c[t][u]=0;
- for (int v = 0; v < j; v++)
- {
- c[t][u] += a[t][v]*b[v][u];
- }
- }
- cout << endl;
- }
- for (int t = 0; t < j; t++)
- {
- for (int u = 0; u < l; u++)
- {
- cout<<" "<<c[t][u];
- }
- cout << endl;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement