CARVIEW |
Select Language
HTTP/2 200
date: Sat, 11 Oct 2025 16:27:18 GMT
content-type: text/html; charset=UTF-8
server: cloudflare
x-frame-options: DENY
x-content-type-options: nosniff
x-xss-protection: 1;mode=block
vary: accept-encoding
cf-cache-status: DYNAMIC
content-encoding: gzip
set-cookie: _csrf-frontend=d86866395984cfc59ea537387b3a1f5f2c9376b14d2045e0ee6eda30357c23dba%3A2%3A%7Bi%3A0%3Bs%3A14%3A%22_csrf-frontend%22%3Bi%3A1%3Bs%3A32%3A%22FJgsAbfymiF-o2DDZ-dbiM6E_cVtQmAK%22%3B%7D; HttpOnly; Path=/
cf-ray: 98cfb95afeafc169-BLR
Priority Queue - Pastebin.com
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <queue>
- #include <string>
- #include <sstream>
- #include <locale.h>
- using namespace std;
- ///////////////////////////////////////////////////////////////////////////
- int main()
- {
- setlocale(LC_ALL, "rus");
- // Приоритетная очередь (по умолчанию
- priority_queue<int> pq; // максимальный элемент наверху)
- int n; // Ввод количества чисел
- cout << "Введите количество операций: "; cin >> n;
- cin.ignore(); // Игнорируем оставшийся символ новой строки
- for (int i = 0; i < n; ++i) // Обработка команд
- {
- string command;
- cout << "Введите команду (Insert <число>): ";
- getline(cin, command);
- stringstream ss(command); // Разбор команды
- string action;
- int value;
- ss >> action;
- if(action == "ExtractMax")
- {
- cout << pq.top() << " " << endl; // Печатаем верхний элемент
- pq.pop(); // Удаляем верхний элемент
- }
- else
- {
- if(action == "Insert")
- {
- ss >> value;
- pq.push(value); // Добавляем число в очередь
- cout << "Добавлено: " << value << endl;
- } else {
- cout << "Неизвестная команда: " << action << endl;
- }
- }
- }
- // Вывод содержимого очереди
- cout << "Содержимое приоритетной очереди (от большего к меньшему):" << endl;
- while (!pq.empty())
- {
- cout << pq.top() << " "; // Печатаем верхний элемент
- pq.pop(); // Удаляем верхний элемент
- }
- cout << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
-
⭐✅ Marketplace Glitch ✅ Working ✅ NEVER SEEN...
JavaScript | 3 sec ago | 0.24 KB
-
⭐⭐Exchange Exploit⭐⭐ 5
JavaScript | 5 sec ago | 0.24 KB
-
✅⭐ Make $2500 in 15 minutes ✅ NEVER SEEN BEFO...
JavaScript | 13 sec ago | 0.24 KB
-
✅⭐ Make huge profits on trading ⭐⭐ T
JavaScript | 16 sec ago | 0.24 KB
-
⭐✅ MAKE $2500 IN 15 MIN⭐⭐⭐ 6
JavaScript | 18 sec ago | 0.24 KB
-
⭐✅ MAKE $2500 IN 15 MIN⭐⭐⭐ I
JavaScript | 27 sec ago | 0.24 KB
-
⭐✅ Exploit 2500$ in 15 Minutes⭐⭐⭐ E
JavaScript | 29 sec ago | 0.24 KB
-
⭐✅ Trading Profit Method ✅ NEVER SEEN BEFORE...
JavaScript | 31 sec ago | 0.24 KB
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand