STL in CPP
STL in CPP
Algorithms- basic searching and sorting algorithms, min-max algorithm, set operations, heap
sort,
binary_search
// binary_search example
#include <iostream> // std::cout
#include <algorithm> // std::binary_search, std::sort
#include <vector> // std::vector
int main () {
int myints[] = {1,2,3,4,5,4,3,2,1};
std::vector<int> v(myints,myints+9); // 1 2 3 4 5 4
3 2 1
return 0;
}
C++ STL std::minmax() function
minmax() function is a library function of algorithm header, it is used to find the smallest and largest values, it
accepts two values and returns a pair of the smallest and largest values, the first element of the pair contains
the smallest value and the second element of the pair contains the largest value.
Note:To use minmax() function – include <algorithm> header or you can simple
use <bits/stdc++.h> header file.
int main()
{
int a = -10;
int b = -20;
return 0;
}