#include <iomanip>
#include <iostream>
#include <vector>
typedef std::vector<std::vector<int>> vector2d;
vector2d CreateVector2d()
{
vector2d v2d(3, std::vector<int>(3));
for (unsigned i = 0; i < 3; ++i)
v2d[i][i] = 1;
return v2d;
}
void print(std::ostream& os, const vector2d& v)
{
// C++11:
for (auto & vec : v)
{
for (auto & i : vec)
os << std::setw(2) << i;
os << '\n';
}
// or:
//for (vector2d::const_iterator i = v.begin(); i != v.end(); ++i)
//{
// for (std::vector<int>::const_iterator j = i->begin(); j != i->end(); ++j)
// os << std::setw(2) << *j;
// os << '\n';
//}
// or:
//for (unsigned i = 0; i < v.size(); ++i)
//{
// for (unsigned j = 0; j < v[i].size(); ++j)
// os << std::setw(2) << v[i][j];
// os << '\n';
//}
}
int main()
{
print(std::cout, CreateVector2d());
}
I2luY2x1ZGUgPGlvbWFuaXA+CiNpbmNsdWRlIDxpb3N0cmVhbT4KI2luY2x1ZGUgPHZlY3Rvcj4KCnR5cGVkZWYgc3RkOjp2ZWN0b3I8c3RkOjp2ZWN0b3I8aW50Pj4gdmVjdG9yMmQ7Cgp2ZWN0b3IyZCBDcmVhdGVWZWN0b3IyZCgpCnsKICAgIHZlY3RvcjJkIHYyZCgzLCBzdGQ6OnZlY3RvcjxpbnQ+KDMpKTsKCiAgICBmb3IgKHVuc2lnbmVkIGkgPSAwOyBpIDwgMzsgKytpKQogICAgICAgIHYyZFtpXVtpXSA9IDE7CgogICAgcmV0dXJuIHYyZDsKfQoKdm9pZCBwcmludChzdGQ6Om9zdHJlYW0mIG9zLCBjb25zdCB2ZWN0b3IyZCYgdikKewogICAgLy8gQysrMTE6CiAgICBmb3IgKGF1dG8gJiB2ZWMgOiB2KQogICAgewogICAgICAgIGZvciAoYXV0byAmIGkgOiB2ZWMpCiAgICAgICAgICAgIG9zIDw8IHN0ZDo6c2V0dygyKSA8PCBpOwogICAgICAgIG9zIDw8ICdcbic7CiAgICB9CgogICAgLy8gb3I6CgogICAgLy9mb3IgKHZlY3RvcjJkOj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