Advertisement
newb_ie

Untitled

Oct 4th, 2021
220
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.59 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main () {
  5. ios::sync_with_stdio(false);
  6. cin.tie(nullptr);
  7. cout.tie(nullptr);
  8. vector<int> v;
  9. v.push_back(15); //insertion operation
  10. v.push_back(10);
  11. v.push_back(20);
  12. //~ cout << v.size() << '\n'; //size of vector
  13. //~ for (int i = 0; i < v.size(); i++) {
  14. //~ cout << v[i] << ' ';
  15. //~ }
  16. //v.begin(); //beginning point
  17. //v.end(); //ending point
  18. //~ cout << "BEFORE SORTING : \n";
  19. //~ for (int i = 0; i < v.size(); ++i) {
  20. //~ cout << v[i] << ' ';
  21. //~ }
  22. sort(v.begin(),v.end()); //accending order
  23. //~ cout << "\nAFTER SORTING : \n";
  24. //~ for (int i = 0; i < v.size(); ++i) {
  25. //~ cout << v[i] << ' ';
  26. //~ }
  27. //~ cout << "\nDECENDING ORDER\n";
  28. //~ sort (v.rbegin(),v.rend()); //decending order
  29. //~ for (int i = 0; i < v.size(); ++i) {
  30. //~ cout << v[i] << ' ';
  31. //~ }
  32. //binary_search(starting_point,ending_point,x); // 0(x nai) , 1(x ache)
  33. //~ int x = 11;
  34. //~ int f = binary_search(v.begin(),v.end(),x); //time complexity = log2(n)
  35. //~ cout << f << '\n';
  36. //~ if (f == 1) {
  37. //~ cout << "ACHE\n";
  38. //~ } else {
  39. //~ cout << "NAI\n";
  40. //~ }
  41. //upper_bound(starting_point,ending_point,x) //it will return imi greater value
  42. //lower_bound(starting_point,ending_point,x) //it will return x if x is present otherwise upper_bound
  43. //~ auto it = upper_bound(v.begin(),v.end(),20);
  44. //~ if (it == v.end()) {
  45. //~ cout << "YES\n";
  46. //~ }
  47. //10,15,20
  48. //~ auto it = lower_bound(v.begin(),v.end(),21);
  49. //~ if (it == v.end()) {
  50. //~ cout << "YES\n";
  51. //~ }
  52. }
  53.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement