#include<fstream>
using namespace std;
ifstream fin("dateo.in");
ofstream fout("dateo.out");
int main()
{
int x,i,n,a[100],s,d,m,gasit=0;
fin>>n;
for(i=1;i<=n;i++) fin>>a[i];
fin>>x;
s=1; d=n;
while(s<=d && !gasit)
{
m=(s+d)/2;
if(a[m]==x) gasit=1;
else if(a[m]<x) s=m+1;
else d=m-1;
}
if(gasit) fout<<m;
else fout<<"Nu se gaseste";
fin.close();
fout.close();
return 0;
}
|