Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include "queue.h"
- #include <fstream>
- using namespace std;
- int main()
- {
- ifstream in("input.txt");
- ofstream out("output.txt");
- Queue<int> getNumb;
- int x,i;
- cin >> x;
- while (in>>i)
- {
- getNumb.Put(i);
- }
- while (!getNumb.Empty())
- {
- if (x != getNumb.Get())
- {
- out << getNumb.Get() << " ";
- }
- in.close();
- out.close();
- return 0;
- }
- }
- using namespace std;
- template <class Item>
- class Queue
- {
- private:
- struct Element
- {
- Item inf;
- Element *next;
- Element(Item x) : inf(x), next(0) {}
- };
- Element *head, *tail;
- public:
- Queue() : head(0), tail(0) {}
- bool Empty()
- {
- return head == 0;
- }
- Item Get()
- {
- if (Empty())
- {
- return 0;
- }
- else
- {
- Element *t = head;
- Item i = t->inf;
- head = t->next;
- if (head == 0)
- tail = 0;
- delete t;
- return i;
- }
- }
- void Put(Item data)
- {
- Element *t = tail;
- tail = new Element(data);
- if (!head)
- {
- head = tail;
- }
- else
- {
- t->next = tail;
- }
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment