Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <queue>
- #include <list>
- #include <vector>
- using namespace std;
- bool clearQue(queue<int>& cque);
- void queIsEmpty(queue<int>& eque);
- void printQue(queue<int> pque);
- bool pasteQue(queue<int>& inque);
- void extractQue(queue<int>& fromque, int& el);
- void goToList(queue<int>& que, list<int>& lis);
- void printList(list<int> plis);
- int main()
- {
- setlocale(LC_ALL, "");
- queue<int> que;
- list<int> lis;
- vector<int> vec;
- int ext_el, first, last;
- for (int i = 0; i < 5; i++)
- {
- int el;
- cin >> el;
- que.push(el);
- }
- //printQue(que);
- goToList(que, lis);
- first = lis.front();
- last = lis.back();
- cout << "в) ";
- printList(lis);
- cout << "Первое звено списка - " << first << ", последнее звено списка - " << last;
- }
- bool clearQue(queue<int>& cque)
- {
- if (cque.empty())
- return true;
- for (int i = cque.size(); i > 0; i--)
- {
- cque.front();
- cque.pop();
- }
- return true;
- }
- void queIsEmpty(queue<int>& eque)
- {
- if (eque.empty())
- cout << "\nОчередь пустая";
- else cout << "\nОчередь не пустая";
- }
- void printQue(queue<int> pque)
- {
- while (!pque.empty())
- {
- int el = pque.front();
- pque.pop();
- cout << el << " ";
- }
- }
- bool pasteQue(queue<int>& inque)
- {
- cout << "\nЭлемент для вставки: ";
- int el;
- cin >> el;
- inque.push(el);
- return true;
- }
- void extractQue(queue<int>& fromque, int& el)
- {
- el = fromque.front();
- fromque.pop();
- }
- void goToList(queue<int>& copque, list<int>& coplis)
- {
- while (!copque.empty())
- {
- coplis.push_front(copque.front());
- copque.pop();
- }
- }
- void printList(list<int> plis)
- {
- while (!plis.empty())
- {
- cout << plis.front() << " ";
- plis.pop_front();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment