Yarim-statik tuzilmalar Navbat va undagi amallar. Navbatlarni tasvirlash. Dek va undagi amallar


Download 380.16 Kb.
bet3/4
Sana19.01.2023
Hajmi380.16 Kb.
#1102305
1   2   3   4
Bog'liq
10 мавзуStek, navbat va dek Stek, navbat va deklarni massiv yordamida

Dek ustida bajariladigan amallar

Dekni quyi chegaralari birlashtirilgan ikkita stek ko’rinishda qarash mumkin.

Deklar bilan ishlash uchun ham C++ da alohida kutubxona mavjud:

#include

Deque dek1;

Dek ustida bajariladigan amallar:

  • boshidan element kiritish. Push_front()
  • Oxiridan element kiritish. Push_back()
  • boshidan element chiqarish. pop_front()
  • oxiridan element chiqarish. Pop_back()
  • Empty() – bo’shlikka tekshirish.

Dek ustida bajariladigan amallar

  • Insert – element qo’yish.
  • Remove – dekdan elementni chiqarib tashlash.
  • Empty – bo’sh yoki bo’sh emasligini tekshirish.
  • Full – to’lalikka tekshirish.

Dekka oid misol keltiramiz:

#include
#include
int main (){
std::deque mydeque (2,100); // two
ints with a value of 100
mydeque.push_front (200);
mydeque.push_front (300);
std::cout << "mydeque contains:";
for (std::deque::iterator it =
mydeque.begin(); it != mydeque.end(); ++it)
std::cout << ' ' << *it;
std::cout << '\n';
return 0;
}
Natija:
300 200 100 100

Stekdagi asosiy amallar

  • Stekga element qo’shish:
  • Push(S,i) –, bu yerda S stek nomi, i - stekga kiritiladigan element;

  • Stekdan element tanlab olish:
  • Pop(S)

  • Stekni bo’sh yoki bo’sh emasligini tekshirish:
  • Empty(S) – (natija: true - bo’sh, false – bo’sh emas);

  • Stekdan elementni tanlovsiz o’qish:
  • StackTop(S)

  • Stekdan elementni o’chirish:
  • Remove (S)

  • Stekning to’liqligini tekshirish:

  • Download 380.16 Kb.

    Do'stlaringiz bilan baham:
1   2   3   4




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