Advertisement
pdpd123

Untitled

Feb 18th, 2019
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.17 KB | None | 0 0
  1. /// 9. standard template library (STL)
  2.  
  3. #include<bits/stdc++.h>
  4. using namespace std;
  5.  
  6. signed main(){
  7.  
  8.     vector<int> vec; // some dynamic length array
  9.     vec.push_back(1); // push something back to the vector
  10.     vec.pop_back(); // pop something back out of the vector
  11.     cin >> vec.at(2); // like arr[2]
  12.     cout << vec[2] << endl; // or use square bracket
  13.    
  14.     stack<int> sta;
  15.     queue<int> que;
  16.     deque<int> dq; // sound like /dik'iu/
  17.     priority_queue<int> pq; // some container adapter using vector
  18.    
  19.     set<int> se; // a set
  20.     multiset<int> mse; // a multi-set
  21.     se.insert(3); // insert something in the set
  22.     se.erase(3); // delete something out of the set
  23.     se.count(3); // if found 3 in the set, return 1; else return 0
  24.    
  25.     int arr[100],n=10;
  26.     vector<int> ve;
  27.    
  28.     sort(arr,arr+n); // sort the array arr[0]~arr[n-1] in increasing order
  29.     sort(arr,arr+n,greater<int>) // decreasing order
  30.     sort(ve.begin(),ve.end()) // vector sorting
  31.    
  32.     pair<int,int> pii; // a pair, just a pair
  33.     cin << pii.first << pii.second;
  34.     cout << pii.second;
  35.    
  36.     /// ** Don't forget to add ';' at the end of the statement **
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement