ممكن أعرف و ين الخطأ بالكود
#include<iostream.h>
void main ()
{
const n=5;
int a[n]={1,2,3,4,5};
for (int i=0;i<=4;i++)
cout<<a<<" ";
do
{
int location,left=0,right=n-1;
int found=0,target;
cin>>target;
while(!found&&left<=right)
{
location=(left+right)/2;
found=(a[location]==target);
if (a[location]<target) left=location+1;
else right=location-1;
}
if (found)cout<<location<<endl;
if (!found)cout<<"not found"<<endl; }
}