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

       

n3 can be inserted at


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

int main () { int array[20]; for (int i = 0; i < 20; i++) { array[i] = i/4; cout << array[i] << ' '; } cout << "\ n3 can be inserted at index: " << upper_bound (array, array + 20, 3) - array << 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: " << upper_bound (str, str + strCt, "d", char_str_less) - str << endl; return 0; }


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