Advertisement
vaibhav1906

Vector

Nov 16th, 2021
2,316
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.46 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2.  
  3. using namespace std;
  4. int main(){
  5.    
  6.     vector<int> v;
  7.    
  8.     v.push_back(34);
  9.     v.push_back(45);
  10.     v.push_back(21);
  11.    
  12.     int s = v.size(); //3
  13.    
  14.     for(int i=0; i<s; i++){
  15.         cout<<v[i]<<endl;
  16.     }
  17.    
  18.     //A vector of size 5, and all values are 1
  19.    
  20.     vector<int> arr(5,1);
  21.    
  22.     for(int i = 0; i<arr.size(); i++){
  23.         cout<<"arr value = "<<arr[i]<<endl;
  24.     }
  25.    
  26.     vector<vector<int>> a(3, vector<int>(4,0));
  27.    
  28.     int sizeOfColumn = v[0].size();
  29.    
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement