Руководство по стандартной библиотеке шаблонов STL

       

n3 can be inserted at


#include <stl.h> #include <iostream.h>

int main () { vector <int> v1 (20); for (int i = 0; i < v1.size (); i++) { v1[i] = i/4; cout << v1[i] << ' '; } int* location = lower_bound (v1.begin (), v1.end (), 3); cout << "\ n3 can be inserted at index: " << (location - v1.begin ()) << endl; return 0; }



#include <stl.h> #include <iostream.h> #include <string.h>

bool char_str_less ( const char* a_, const char* b_) { return ::strcmp (a_, b_) < 0 ? 1 : 0; }

char* str [] = { "a", "a", "b", "b", "q", "w", "z" };

int main () { const unsigned strCt = sizeof (str)/sizeof (str[0]); cout << "d can be inserted at index: " << (lower_bound (str, str + strCt, "d", char_str_less) - str) << endl; return 0; }


Содержание раздела