Search
 
SCRIPT & CODE EXAMPLE
 

CPP

2d vector c++ size

vector<vector<int>> a;
int r=a.size() //gives no of rows
  int c=a[0].size() //gives no of columns
Comment

how to get size of 2d vector in c++

myVector[
  Vector[0, 4, 2, 5],
  Vector[1, 4, 2]
];

/*When you call for myVector[1].size() it would return 3 and [0] would return 4.

For the amount of rows (int vectors) in the 2d vector, you can just use myVector.size()

You can run this to see it in actions*/
Comment

2d vector size c++

#include <iostream>
#include <vector>

int main(){
    std::vector<std::vector<int>>MyVector;
  std::cout << "Rows in the 2d vector: " << MyVector.size() <<
    std::endl << "Collumns in the 1st row: " << MyVector[0].size() <<
    std::endl;
  return 0;
}
Comment

PREVIOUS NEXT
Code Example
Cpp :: c++ calorie calculator using a for loop 
Cpp :: map update field elixir 
Cpp :: & before function arg in cpp 
Cpp :: // A C++ program to show that we can use reference to 
Cpp :: temporary variable ex c++ 
Cpp :: 2160. Minimum Sum of Four Digit Number After Splitting Digits leetcode solution in c++ 
Cpp :: flutter websocket auto reconnect 
Cpp :: pca compact trick 
Cpp :: Structure of s void function 
Cpp :: Smooth Poti values on Arduino 
Cpp :: QMetaObject_invokeMethod 
Cpp :: c++ how to print out 
Cpp :: pointeur cpp 
Cpp :: ex:c++ gcc start adress 
Cpp :: operator = overloading c++ 
Cpp :: how to pass arrays by reference c++ 
Cpp :: cin in c++ 
Cpp :: Set Specific Time in youtube Video url 
Cpp :: constructor overloading in c++ 
Cpp :: c++ loop array 
Cpp :: dream speedrun music free download mp3 
C :: remix icon cdn 
C :: c get time in milliseconds 
C :: find maximum number between 3 numbers in c 
C :: if statement shorthand c 
C :: How to generate a random array in c 
C :: print ascii value in c 
C :: add field to model rails 
C :: how to create calculator with switch in c 
C :: how to check if a string pointer is empty in c 
ADD CONTENT
Topic
Content
Source link
Name
5+4 =