print 2d vector c++
for(int i=0; i<v.size(); i++)
for(int j=0; j<v[i].size(); j++)
cout<<v[i][j]<<" ";
cout<<endl;
print 2d vector c++
for(int i=0; i<v.size(); i++)
for(int j=0; j<v[i].size(); j++)
cout<<v[i][j]<<" ";
cout<<endl;
print 2d array c++
for( auto &row : arr) {
for(auto col : row)
cout << col << " ";
cout<<endl;
}
print a 2d vector in c++
// A recursive function able to print a vector
// of an arbitrary amount of dimensions.
template<typename T>
static void show(T vec)
{
std::cout << vec;
}
template<typename T>
static void show(std::vector<T> vec)
{
int size = vec.size();
if (size <= 0) {
std::cout << "invalid vector";
return;
}
std::cout << '{';
for (int l = 0; l < size - 1; l++) {
show(vec[l]);
std::cout << ',';
}
show(vec[size - 1]);
std::cout << '}';
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us