Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <algorithm>
- #include <clocale>
- using namespace std;
- int main() {
- setlocale(LC_ALL, "");
- const int SIZE_A = 5, SIZE_B = 3;
- int haystack[SIZE_A] = {1, 3, 4, 5, 9};
- int needles[SIZE_B] = {1, 2, 3};
- // haystack - массив, в котором будет происходить поиск
- // needles - массив чисел, которые будет искать функция в массиве haystack
- for (int i = 0; i < SIZE_B; ++i) {
- cout << "Поиск " << needles[i] << "..." << endl;
- if (binary_search(haystack, haystack + SIZE_A, needles[i]))
- cout << "Найдено " << needles[i] << endl;
- else
- cout << "Не найдено!" << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement