#include #include #include using namespace std; int main () { int x [] = {2, 7, 92, 81, 19, 72, 23}; unsigned int array_length = sizeof (x) / sizeof (int); cout
Tag: STL : algorithm
STL: Algorithm: generate ()
#include #include using namespace std; int main () { vector v (10); // allocate space for 10 elements generate( v.begin (), v.end (), rand); // generate random numbers for ( size_t i = 0; i < v.size (); i++ ) printf ("%d\n", v [i]); return 0; } /* output 41 18467 6334 26500 19169 15724 … Continue reading STL: Algorithm: generate ()
STL: Algorithm: binary_search ()
STL: Algorithm: prev_permutation ()
STL : find ()
If the value of key is equals to: 2 / 4 / 6 / 8 / 10 output will be found. vector <int>:: iterator p; declares a variable p, that traverse the whole vector form begin to end. p saves the address of key, if found. So, If (*p is equals to key) then, output: … Continue reading STL : find ()