main()
{
int n;
cout<<"n=";cin>>n;
struct malumot
{
string FISH,tugulgan_sana, pasport;
}
shaxs[n];
for(int i=0;i
{
cout<>shaxs[i].FISH;
cout<<"Tugulgan_sana =";cin>>shaxs[i].tugulgan_sana;
cout<<"Pasport =";cin>>shaxs[i].pasport;
}
for(int i=0;i
for(int j=i+1;j
if(shaxs[i].FISH>shaxs[j].FISH)
{
malumot h=shaxs[i];
shaxs[i]=shaxs[j];
shaxs[j]=h;
}
for(int i=0;i
cout<
cout<
int low = 0,hi = n-1,search=-1,q=0;
string key; cout<<"kalit = ";
cin>>key;
while(low<=hi)
{
int mid = (low + hi) / 2;
q++;
if (key == shaxs[mid].FISH)
{
search = mid;
break;
}
if (key < shaxs[mid].tugulgan_sana)
hi = mid - 1;
else low = mid + 1;
}
if(search!=-1) cout<<"qidirilayotgan element "<
else
{
cout<
system("PAUSE");
return 0;
}
while(shaxs[search-1].FISH==key) search--;
while(shaxs[search].tugulgan_sana==key)
{
cout<
search++;
}
system("pause");
}
Natija:
Do'stlaringiz bilan baham: |