OBed

mail@pastecode.io avatar
unknown
plain_text
a year ago
729 B
0
Indexable
Never
#include <iostream>



using namespace std;
int main()
{

	int mas[10][10], N, M, t;

	cin >> N >> M;

	for (int i = 0; i < N; i++)
	{
		for (int j = 0; j < M; j++)
		{
			cin >> mas[i][j];
		}
	}

	cin >> t;

	for (int i = 0; i < t; i++)
	{

		int I, J;
		char znak;
		
		cin >> znak >> I >> J;

		for (int j = 0; j < N; j++)
		{

			if (znak == '+') mas[j][J - 1] += mas[j][I - 1];

			else if (znak == '-') mas[j][J - 1] -= mas[j][I - 1];

			else if (znak == '*') mas[j][J - 1] *= mas[j][I - 1];

			else mas[j][J - 1] /= mas[j][I - 1];

		}

	}

	for (int i = 0; i < N; i++)
	{
		for (int j = 0; j < M; j++)
		{
			cout << mas[i][j] << " ";
		}

		cout << endl;
	}


}