//(c)Terminator
#include <iostream>
#include <iterator>
using namespace std;



int main(void){
	const int N = 3;

	int ma[N][N] = {
		{ 1, 2, 3 },
		{ 4, 3, 1 },
		{ 0, 1, 2 }
	};
	
	int mb[N][N] = {
		{ 2, 1, 8 },
		{ 3, 4, 1 },
		{ 9, 4, 2 }
	};

	int mc[N][N];
	int i;


	//перемножение
	for(int ir = 0; ir < N; ++ir) {
		for(int c = 0; c < N; ++c) {
			mc[ir][c] = 0;
			for(int r = 0; r < N; ++r) 
				mc[ir][c] += ma[ir][r] * mb[r][c];
		}
	}

	//вывести результирующею матрицу
	ostream_iterator<int> _op(cout, "\t");
	for(i = 0; i < N; ++i){
		copy(mc[i], mc[i] + N, _op);
		cout << endl;
	}

	//...

	//транспонирование
	for(i = 0; i < N; ++i) {
		for(int j = i; j < N; ++j)
			swap(mc[i][j], mc[j][i]);
	}

	cout << endl;
	for(i = 0; i < N; ++i){
		copy(mc[i], mc[i] + N, _op);
		cout << endl;
	}
	return 0;
}
