#include <iostream>
using namespace std;

template<int W, int H>
class martrix{
    float _m[W][H];
public:
    martrix(){
        for (int x=0;x<W;x++)
            for (int y=0;y<H;y++)
                _m[x][y] = 0;
    }
    
    float & at(int x, int y){
        return _m[x][y];
    }
    
    void set(float m[W][H]){
        for (int x=0;x<W;x++)
            for (int y=0;y<H;y++)
                _m[x][y] = m[x][y];
    }
    
    const martrix<W,H> add(const martrix<W,H>& m)const{
        martrix<W,H> tmp;
        for (int x=0;x<W;x++)
            for (int y=0;y<H;y++)
                tmp._m[x][y] = _m[x][y] + m._m[x][y];
        return tmp;
    }
    
    template<int WW>
    const martrix<WW,H> mul(const martrix<WW,W>& m)const{
        martrix<WW,H> tmp;
        for (int x=0;x<WW;x++)
            for (int y=0;y<H;y++)
                for (int i=0;i<W;i++)
                    tmp.at(x,y) += at(i,y) * at(x,i);
        return tmp;
    }
    
    void print(ostream& out){
        for (int y=0;y<H;y++)
        {
            for (int x=0;x<W;x++)
                out << _m[x][y] << " ";
            out << endl;
        }
    }
};


int main()
{
    martrix<3,2> A,
                 B;
    
    A.print(cout);
    
    float a[2][3] = {
                    {1, 2, 3},
                    {4, 5, 6},
                    };
    float b[3][2] = {
                    {7, 8},
                    {9, 10},
                    {11, 12},
                    };
    A.set(b);
    B.set(a);

    return 0;
}
