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);
}
page revision: 0, last edited: 30 Aug 2011 13:15





