This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <vector> | |
using namespace std; | |
vector<int> a = {1, 14, 32, 51, 51, 51, 243, 419, 750, 910}; | |
// 目的の値 key の index を返すようにする (ない場合は -1) | |
int binary_search(int key) | |
{ | |
int left = 0, right = (int)a.size() - 1; // 配列 a の左端と右端 |