Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
1.2 kB
0
Indexable
Never
#include <string>
#include <iostream>
using namespace std;
int main()
{
    int a, b, d, e,t, mass[100][100];
    string c;
    cin >> a >> b;
    for (int i = 0; i < a; i++)
    {
        for (int j = 0; j < b; j++)
        {
            cin >> mass[i][j];
        }
    }
    cin >> t;
    for (int i = 0; i < t; i++)
    {
        cin >> c >> d >> e;
        d -= 1;
        e -= 1;

        if (c == "+") {
            for (int i = 0; i < a; i++)
            {
                mass[i][e] += mass[i][d];
            }
        }
        if (c == "-") {
            for (int i = 0; i < a; i++)
            {
                mass[i][e] -= mass[i][d];
            }

        }
        if (c == "*") {
            for (int i = 0; i < a; i++)
            {
                mass[i][e] *= mass[i][d];
            }

        }
        if (c == "/") {
            for (int i = 0; i < a; i++)
            {
                mass[i][e] /= mass[i][d];
            }

        }
    }
    
    for (int i = 0; i < a; i++)
    {
        for (int j = 0; j < b; j++)
        {
            cout <<  mass[i][j] << " ";
        }
        cout << endl;
    }
}