Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Сама очередь.
- class queue
- {
- private:
- struct queue_ob
- {
- char value;
- queue_ob addr;
- };
- queue_ob head;
- queue_ob tail;
- public:
- int size;
- queue(char x)
- {
- head = new(queue_ob);
- tail = head;
- head->value = x;
- head->addr = 0;
- size = 1;
- }
- char get_value()
- {
- return head->value;
- }
- int stack_size()
- {
- return size;
- }
- void push(char value)
- {
- size++;
- queue_ob temp = new(queue_ob);
- temp->addr = 0;
- temp->value = value;
- tail->addr = temp;
- tail = temp;
- }
- /поправить выдачу из очереди/
- void pop(char ret)
- {
- if (size == 0)
- {
- cout << "Очередь пуста - удалять нечего!" << endl;
- return;
- }
- queue_ob temp = head;
- ret = head->value;
- head = head->addr;
- delete temp;
- size--;
- }
- void peek(char ret)
- {
- if (size == 0)
- {
- cout << "Очередь пуста!" << endl;
- return;
- }
- ret = head->value;
- }
- };
- Забивание данных и выдача
- string line_01;
- char line[50];
- ifstream read_line_01("текстовик с данными");
- getline(read_line_01, line_01);
- char first_line = &line_01[0];
- char char_line = &line_01[1];
- char current_value;
- while (getline(read_line_01, line_01))
- {
- char_line = &line_01[0];
- ob.push(char_line);
- }
- while (ob.size > 1)
- {
- ob.pop(¤t_value);
- str_sep(current_value);
- }
- read_line_01.close();
Advertisement
Add Comment
Please, Sign In to add comment