Ma'lumotlarni dinamik informatsion tuzulmalari



Download 165,91 Kb.
bet4/4
Sana18.11.2022
Hajmi165,91 Kb.
#868099
1   2   3   4
Bog'liq
malumotlarni dinamik informatsion tuzulmalar

Dastur kodi


#include using namespace std; class Node{


public: int number;
Node* next;
};
int main()
{ Node* head = NULL; Node* lastPtr = NULL;
short action = -1; while (1)
{ cout<<"1. element qo’shish\n"; cout<<"2. ro’yhatni ko’rish\n"; cout<<"3. ro’yhat maksimalini topish\n"; cout<<"0. chiqish\n\n";
cout<<"tanlang: "; cin>>action;
if (action == 0) { system("CLS"); break;}
if (action == 1)
{ system("CLS"); Node* ptr = new Node; int numb = -1; cout<<"son kiriting: "; cin>>numb;
ptr->number = numb; ptr->next = NULL;
if (head == 0)
{ head = ptr; lastPtr = ptr; system("CLS"); continue;
}
lastPtr->next = ptr; lastPtr = ptr; system("CLS"); continue;
}
if (action == 2){ Node* ptr = NULL;
system("CLS"); if (head == 0)
{ cout<<"\t!!! ro’yhat bo’sh !!!\n\n"; system("PAUSE");
system("CLS"); continue;
}
cout<<"* * * * * ro’yhat * * * * *\n\n"; ptr = head;
while (1) {
cout<
number<<" "; if (ptr->next == 0) break; ptr = ptr->next;
}
cout<<"\n\n"; system("PAUSE");
system("CLS"); continue;
}
if (action == 3)
{
system("CLS"); Node* p = head; Node* q = new Node;
Node* last = new Node;
int max=p->number; q=head; while(p){
if(max
number){ max=p->number;} p=p->next;
}
system("CLS"); cout<<"max="<system("pause"); continue;
}
}}

Dastur bajarilishi natijasi


  1. element qo’shish

  2. ro’yhatni ko’rish

  3. ro’yhat maksimalini topish

0. chiqish
tanlang:1
{1,2,3,55,4,6} sonlari kiritildi. 2-holat tanlanganda natija:
*****ro’yhat***** 1 2 3 55 4 6
3-holat tanlanganda natija:
max=55


Elementni ochirish dasturi


struct Stack { int info; Stack * next;
} *begin, *t;
Stack* InStack(Stack*, int); void View(Stack*);
void Del_All(Stack **);
int i, in, n = StrToInt(Edit1->Text); if(begin != NULL){
ShowMessage("Xotirani boshating!"); return;
}
for(i = 1; i <= n; i++){ in = random(20);
begin = InStack(begin, in);
}
Memo1->Lines->Add("Yaratdik " + IntToStr(n) + " -ть."); int i, in, n = StrToInt(Edit1->Text);
for(i = 1; i <= n; i++){ in = random(20);
begin = InStack(begin, in);
}
Memo1->Lines->Add("Qoshdik " + IntToStr(n) + " -ть."); if(!begin){
ShowMessage("Stek bosh !"); return;
}
Memo1->Lines->Add("--- Elementlar ---"); View(begin);
if (begin != NULL) Del_All(&begin); ShowMessage("Hotira boshatildi!"); if(begin != NULL) Del_All(&begin); Close();
Stack* InStack(Stack *p, int in) { Stack *t = new Stack;
t -> info = in; t -> next = p; return t;
}
void View(Stack *p) { Stack *t = p; while( t != NULL) {
Form1->Memo1->Lines->Add(" " + IntToStr( t->info)); cout << " " << t->info << endl;
t = t -> next;
}
}
void Del_All(Stack **p) { while(*p != NULL) {
t = *p;
*p = (*p) -> next; delete t;
} }
Download 165,91 Kb.

Do'stlaringiz bilan baham:
1   2   3   4




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

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish