Untitled

mail@pastecode.io avatar
unknown
plain_text
6 months ago
915 B
1
Indexable
Never
#include <iostream>

int main()
{
    int a[2][2] = {
        {2, 3},
        {4, -1}
    };
    int b[2][2] = {
        {1, 0},
        {5, -2}
    };
    int res[2][2] = {
        {0, 0},
        {0, 0}
    };

    //for (int i = 0; i < 2; i++) {
    //    for (int j = 0; j < 2; j++) {
    //        std::cin >> a[i][j];
    //    }
    //}
    //for (int i = 0; i < 2; i++) {
    //    for (int j = 0; j < 2; j++) {
    //        std::cin >> b[i][j];
    //    }
    //}

    for (int i = 0; i < 2; i++) {
        for (int j = 0; j < 2; j++) {
            for (int k = 0; k < 2; k++) {
                    res[i][j] += a[i][k] * b[k][j];
            }
        }
    }

    for (int i = 0; i < 2; i++) {
        for (int j = 0; j < 2; j++) {
            std::cout << res[i][j] << ' ';
        }
    }

    //std::cout << res[0][0] * res[1][1] - res[0][1] * res[1][0];
}
Leave a Comment