Преглед на файлове

Experiment queue with integers

DricomDragon преди 5 години
родител
ревизия
0749bb7ff9
променени са 1 файла, в които са добавени 18 реда и са изтрити 0 реда
  1. 18 0
      containers/main.cpp

+ 18 - 0
containers/main.cpp

@@ -1,9 +1,27 @@
 #include <iostream>
+#include <queue>
 
 using namespace std;
 
 int main() {
 	cout << "Hello containers !" << endl;
 
+	cout << "# Priority queue" << endl;
+	cout << "## With integers" << endl;
+
+	priority_queue<int> pqInt;
+
+	pqInt.push(5);
+	pqInt.push(2);
+	pqInt.push(0);
+	pqInt.push(42);
+	pqInt.push(3);
+
+	while (!pqInt.empty()) {
+		cout << pqInt.top() << " > ";
+		pqInt.pop();
+	}
+	cout << endl;
+
 	return 0;
 }