Kaynağa Gözat

Experiment queue with integers

DricomDragon 5 yıl önce
ebeveyn
işleme
0749bb7ff9
1 değiştirilmiş dosya ile 18 ekleme ve 0 silme
  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;
 }