Advertisement
Jambix64

UsingVactor

Sep 4th, 2016
475
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.72 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <algorithm>
  4.  
  5. using namespace std;
  6.  
  7. // c.push_back(25); add element at the vector.
  8. // c.size() size of the vector, parameter empty
  9. // c.begin() start
  10. // c.end()   end
  11. int main(){
  12.    
  13.     vector <int> c;
  14.     c.push_back(11);
  15.     c.push_back(10);
  16.     c.push_back(11);
  17.     c.push_back(8);
  18.     c.push_back(20);
  19.     //function sort  ( begin inicio , end fim)
  20.     sort(c.begin(), c.end());
  21.      //int tm = c.size;
  22.      //adicionar o tm no segundo parameter do for, também funciona;
  23.     for (int i = 0;i<(int)c.size(); i++)
  24.         cout<<c[i]<<"\n";
  25.  
  26.     cout<<c.size()<<" Position \n";
  27.  
  28.     c.clear();
  29. // delete buffer
  30. // check class vector
  31.     cout << endl;
  32.     cout << c.size() << " Position \n";
  33.     return 0;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement