Yurttas/PL/OOL/Cplusplus/F/07/01/04/00/pq 00.cpp

From ZCubes Wiki
Jump to navigation Jump to search
 1/*
 2   Copyright(C) 1998
 3   All Rights Reserved. Salih Yurttas, ZCubes, BitsOfCode Software Systems, Inc..
 4
 5   Permission to use, copy, modify, and distribute this
 6   software and its documentation for I_ADUCATIONAL purposes
 7   and without fee is hereby granted provided that this
 8   copyright notice appears in all copies.
 9
10   date   : January 1, 1998.
11   author : Salih Yurttas.
12
13   pq_00.cpp
14*/
15
16
17#include <iostream>
18
19#include <vector>
20#include <queue>
21
22using namespace std;
23
24int main(int argc, char* argv[]) {
25
26  priority_queue<int> pq_0;
27
28  pq_0.push(2);
29  pq_0.push(1);
30  pq_0.push(9);
31  pq_0.push(5);
32  pq_0.push(7);
33  pq_0.push(6);
34
35  while(!pq_0.empty()) {
36    cout << pq_0.top() << endl;
37    pq_0.pop();
38  }
39
40  cout << endl;
41
42  priority_queue<int,
43                 vector<int>,
44                 greater<int> > pq_1;
45  
46  pq_1.push(2);
47  pq_1.push(1);
48  pq_1.push(9);
49  pq_1.push(5);
50  pq_1.push(7);
51  pq_1.push(6);
52
53  while(!pq_1.empty()) {
54    cout << pq_1.top() << endl;
55    pq_1.pop();
56  }
57
58}