1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
|
void binsearch(Seat seat[][50],int rows,char firstname[],char lastname[],int assigned)
{
bool found = false;
int mid,first=0,last=assigned;
for (int i = 0; i < rows; i++)
{cout<<'x';
for(int j=0;j++;j<50)
{
while(!found && first <= last)
{
mid = (first + last) / 2;
{
if(stricmp(firstname,seat[i][j].firstname)==0 &&stricmp(lastname,seat[i][j].lastname)==0 )
found = true;
else if(stricmp(lastname,seat[i][j].lastname)<0)
{
first=mid;
}
else if(stricmp(lastname,seat[i][j].lastname)>0)
{
last=mid;
}
else if(stricmp(lastname,seat[i][j].lastname)== 0 && stricmp(firstname,seat[i][j].firstname)<0)
{
first=mid;
}
else if(stricmp(lastname,seat[i][j].lastname)== 0 && stricmp(firstname,seat[i][j].firstname)>0)
{
last=mid;
}
}
}
}
}
if(found)
cout<<endl<<"Customer "<<firstname<<' '<<lastname<<"was found at: ";
else
cout<<"Customer not found"<<endl;
}
|