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


Binsrch2


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

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

char* labels[] = { "aa", "dd", "ff", "jj", "ss", "zz" };

int main () { const unsigned count = sizeof (labels) / sizeof (labels[0]); if (binary_search (labels, labels + count, "ff", str_compare)) cout << "ff is in labels." << endl; else cout << "ff is not in labels." << endl; return 0; }




Начало  Назад  Вперед



Книжный магазин