#include <bits/stdc++.h>
#define ERR -1
std::vector<int> s;
int inp;
int eval(std::vector<int> v, int fl, int fr, int idx) {
if (fr>=fl) {
int idy = fl+(fr-fl)/2;
if (v.at(idy)==idx) return idy;
if (v.at(idy)>idx) return eval(v,fl,idy-1,idx);
return eval(v,idy+1,fr,idx);
}
return ERR;
}
std::string print_result(int input) {
int result = eval(s,0,s.size()-1,input);
return result!=ERR ? "The element found at " + std::to_string(result) + ". index!\\" : "The element not found!\\";
}
void read() {
std::cout << "Enter 20 numbers whether ascending or descending order.\\";
for(int i=0;i<20;i++) {
std::cout << "\\>>";
int fill; std::cin>>fill;
s.push_back(fill);
}
std::cout << "Which element do you want to find?: ";
std::cin>>inp;
}
int main(int argc, char* argv[]) {
read();
std::cout << print_result(inp);
return 0;
}