Binary Search Function

#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
    vector<int>a = {1,2,3,4,5,6,7,8,9,10};
    bool b = binary_search(a.begin(), a.end(), 8);

    if(b == true)
        cout << 8 << " is Found." << endl;
    else
        cout << 8 << " is not Found." << endl;

    return 0;
}

Comments