Sdp20

#include <iostream>

using namespace std;

typedef double INFO_TYPE;

using std::cout;
using std::endl;
typedef float InfoType;

struct Queue_El{
InfoType info;
Queue_El *next;
};

void enqueue(Queue_El *&r, InfoType x){
Queue_El *p = new Queue_El;
if(p == NULL){
cout « "Nqma svobodna pamet! " « endl;
p->info = x;
p->next = NULL;
delete p;
}
}
InfoType dequeue(Queue_El *f, Queue_El *&r){
InfoType x;
Queue_El *p = f->next;

if(p == NULL){
cout « "Opashkata e prazna!" « endl;
f->next = p->next;
x = p->info;
delete p;
if(f->next == NULL)
r = f;
return x;

}
}

int main()
{
Queue_El Q = {0,NULL}, *F = &Q, *R = F;
InfoType y = 3;
enqueue(R, y);
y = dequeue(F,R);

}

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License