SHARE
TWEET

Untitled

a guest Mar 22nd, 2019 50 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <vector>
  3. using namespace std;
  4.  
  5. int main() {
  6.     vector<int> v; //only int type
  7.  
  8.     v.push_back(1);
  9.     v.push_back(2);
  10.     v.push_back(3);
  11.  
  12.     for(int i=0; i<v.size(); i++)
  13.         cout<<v[i]<<" ";          //1 2 3
  14.     cout<<endl;
  15.  
  16.     v[0] = 9;
  17.     int n = v[2];
  18.     v.at(2) = 7;
  19.    
  20.     for(int i=0; i<v.size(); i++)
  21.         cout<<v[i]<<" ";
  22.     cout<<endl;                  //9 2 7
  23. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top