How to get the size of two dimensional (2D) vector in C++

1 Answer

0 votes
#include <iostream>
#include <vector>
  
int main ()
{
    std::vector<std::vector<int>> v {{{1, 2, 3, 4},{5, 6, 7, 8},{9, 10, 11, 12}}};
    
    std::cout << v.size() << "\n"; 
    std::cout << v[0].size();

    return 0;
}
   
   
   
   
/*
run:
 
3
4
    
*/

 



answered Dec 7, 2020 by avibootz

Related questions

1 answer 229 views
1 answer 187 views
2 answers 187 views
1 answer 158 views
2 answers 168 views
...