#include <vector>
#include <iostream>
using namespace std;
// to dla wygody, żeby nie powtarzać tyle razy
typedef vector<vector<int>> vvint;
// dodawanie
vvint operator +(const vvint& a, const vvint& b) {
vvint result;
result.resize(a.size());
for (int x=0;x<a.size();x++)
{
result[x].resize(a[x].size());
for (int y=0;y<a[x].size();y++)
result[x][y] = a[x][y] + b[x][y];
}
return result;
}
// miejmy jak to wyświetlać...
ostream& operator<<(ostream& out, const vvint& v) {
for (int x=0;x<v.size();x++)
{
for (int y=0;y<v[x].size();y++)
{
out<<v[x][y];
if (y<v[x].size()-1)
out<<' ';
}
if (x<v.size()-1)
out<<" | ";
}
return out;
}
// przykładowe tablice - uwaga: to przejdzie tylko w C++0x,
// a nie chce mi się robić push_backów w pętli
vvint tab1 = {{1,2,3},{4,5,6},{7,8,9}};
vvint tab2 = {{2,3,1},{6,5,4},{9,8,7}};
// no i jedziemy
int main()
{
cout << tab1 << " + " << tab2 << " = " << tab1+tab2 << endl;
}