Pagini recente » Cod sursa (job #2344281) | Cod sursa (job #2393273) | Cod sursa (job #1261164) | Cod sursa (job #2556183) | Cod sursa (job #1649480)
#include <bits/stdc++.h>
using namespace std;
int n, a[100003], op, x, m;
int CautBin(int x)
{
int m, st, dr;
m = (st + dr) / 2;
while(st <= dr)
{
if(x == a[m])
return m;
if(x > a[m])
st = m + 1;
else dr = m - 1;
}
return -1;
}
int CautBinSt(int x)
{
return 0;
}
int CautBinDr(int x)
{
return 0;
}
int main()
{
ifstream fin("cautbin.in");
ofstream fout("cautbin.out");
int i;
fin >> n;
for(i = 1; i <= n; ++i)
fin >> a[i];
fin >> m;
for(i = 1; i <= m; ++i)
{
fin >> op >> x;
if(op == 0)
fout << CautBin(x) << "\n";
else if(op == 1)
fout << CautBinDr(x) << "\n";
else fout << CautBinSt(x) << "\n";
}
fout.close();
fin.close();
return 0;
}