Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (INPUT
- 2 2
- 1 2
- 3 4
- OUTPUT
- 5 11
- 11 25)
- #include<iostream>
- using namespace std;
- int a[100][100];
- int b[100][100];
- int c[100][100];
- int n,m;
- void input() {
- cin >> n >> m;
- for(int i = 0; i < n; i++)
- for(int j = 0; j < m; j++)
- cin >> a[i][j];
- }
- void cvi() {
- for(int i = 0; i < n; i++) {
- for(int j = 0; j < m; j++) {
- b[j][i] = a[i][j];
- }
- }
- }
- void tich() {
- for(int i = 0; i < n; i++) {
- for(int j = 0; j < n; j++) {
- for(int l = 0; l < m; l++) {
- c[i][j] += a[i][l] * b[l][j];
- }
- }
- }
- for(int i = 0; i < n; i++) {
- for(int j = 0; j < n; j++) {
- cout << c[i][j] << " ";
- }
- cout << endl;
- }
- }
- int main() {
- input();
- cvi();
- tich();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement