#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
Category: STL documentation
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 : Vector [6] (erase, insert, swap)
/* STL : Vector [6] (erase, insert, swap) Author : Tausiq B.Sc in CTE (Studying) United International University */ #include #include using namespace std; int main () { vector v (5); for ( int i = 0; i < 5; i++ ) v [i] = i * 2; // 0 2 4 6 8 vector … Continue reading STL : Vector [6] (erase, insert, swap)
STL : Vector [5] (empty, pop_back)
/* STL : Vector [5] (empty, pop_back) Author : Tausiq B.Sc in CTE (Studying) United International University */ #include #include using namespace std; int main () { vector v (5); for ( int i = 0; i < 5; i++ ) v [i] = i * 2; for ( int i = 0; i < … Continue reading STL : Vector [5] (empty, pop_back)
STL : Vector [4] (begin, end)
/* STL : Vector [4] (begin, end) Author : Tausiq B.Sc in CTE (Studying) United International University */ #include #include using namespace std; int main () { vector v (5, 1); /* makes a vector of length 5 and fill the vector with value 1 */ vector :: iterator i; /* iterator i works like … Continue reading STL : Vector [4] (begin, end)
STL : Vector [3] (begin, size, clear)
/* STL : Vector [3] (begin, size, clear) Author : Tausiq */ #include #include using namespace std; int main () { vector v; int i; for ( i = 10; i < 50; i += 10 ) v.push_back ( i ); // 10 20 30 40 printf ("begin : %d\n", *v.begin () ); printf ("size … Continue reading STL : Vector [3] (begin, size, clear)
STL : Vector [2] (push_back, at, back, front)
/* STL : Vector [2] (push_back, at, back, front) Author : Tausiq B.Sc in CTE United International University */ #include "stdio.h" #include "vector" using namespace std; int main () { vector v; int i; for ( i = 0; i < 5; i++ ) v.push_back ( i + 65 ); for ( i = 0; … Continue reading STL : Vector [2] (push_back, at, back, front)
STL : Vector [1] (Introduction)
:: Vector :: ( Introduction ) ::