3-Laboratoriya ishidan Xisoboti


Download 188.18 Kb.
bet2/2
Sana03.06.2020
Hajmi188.18 Kb.
#113693
1   2
Bog'liq
lab 3


2 – topshiriq

Ustuvor navbatda elementlar sonini topish va eng katta elementni yechib olish funksiyasi.


#include

#include

using namespace std;

void showpq(priority_queue gq)

{

priority_queue g = gq;



while (!g.empty())

{


cout << '\t' << g.top();

g.pop();

}

cout << '\n';



}

int main ()

{

priority_queue gquiz;



gquiz.push(10);

gquiz.push(30);

gquiz.push(20);

gquiz.push(5);

gquiz.push(1);

cout << "Ustuvor navbat elementlari : ";

showpq(gquiz);

cout << "\nelementlar soni : " << gquiz.size();

cout << "\nMax element : " << gquiz.top();

cout << "\nQolgan elementlar : ";

gquiz.pop();

showpq(gquiz);



return 0;

}


Download 188.18 Kb.

Do'stlaringiz bilan baham:
1   2




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