Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #define QMAX 100
- using namespace std;
- struct Queue // Структура данных
- {
- int qu[QMAX];
- int rear, frnt;
- };
- void *queue_create(struct Queue *que) {
- que->frnt = 1;
- que->rear = 0;
- return que;
- }
- void queue_insert(struct Queue *que, int data) // включение элемента в очередь
- {
- if (que->rear < QMAX - 1) {
- que->rear++;
- que->qu[que->rear] = data;
- }
- }
- bool queue_empty(struct Queue *que) { // проверка очереди на наличие элементов
- return que->rear < que->frnt;
- }
- void queue_remove(struct Queue *que, int data) // исключение элемента из очереди
- {
- if (queue_empty(que) == 1) {
- return;
- }
- data = que->qu[que->frnt];
- que->frnt++;
- }
- int queue_get(struct Queue* que) {
- return que->qu[que->frnt];
- }
- void queue_clear(struct Queue *que) { // удаление очереди
- delete[] que->qu;
- que->frnt = 0;
- que->rear = 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement