3- mavzu. Xesh jadval va xesh funksiyalar. Xesh funksiyalarga misol


main() { int n; coutn; struct malumot


Download 157.58 Kb.
bet6/6
Sana12.11.2023
Hajmi157.58 Kb.
#1768031
1   2   3   4   5   6
Bog'liq
3 mavzu Xesh jadval va xesh funksiyalar Xesh funksiyalarga mi fayllar

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;jif(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:




http://fayllar.org
Download 157.58 Kb.

Do'stlaringiz bilan baham:
1   2   3   4   5   6




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling