Return to Snippet

Revision: 53921
at December 3, 2011 06:28 by bagrancar


Initial Code
#include <cstdlib>
#include <iostream>
using namespace std;
struct tpopis
{ int rb;
int x;
int y;
int p;
};
 
struct t{
tpopis popis;
t *sljedeci;
};
 
struct r{
t *front, *rear;
};
 
void initq(r *red){
red->front=(t*)malloc(sizeof(t));//alociranje pokazivaca front
red->front->sljedeci=NULL;
red->rear=red->front;
cout<<"Red je inicijaliziran"<<endl;
};
 
bool isemptyq(r *red){
if(red->front==red->rear) return true;
else return false;
};
 
void enqueueq(tpopis x,r *red){
t *pom;
pom=new t;
pom->popis=x;
pom->sljedeci=NULL;
red->rear->sljedeci=pom;
red->rear=pom;
};
 
void dequeueq(r *red){
t *pom;
if(isemptyq(red)) cout<<"Red je trenutno prazan!";
else{
pom=red->front;
red->front=red->front->sljedeci;
free(pom);
}
};
 
tpopis frontq(r *red){
if(isemptyq(red)) cout<<"Red je trenutno prazan!";
else return (red->front->sljedeci->popis);
};

Initial URL
www.snipplr.com/strukture_biblioteka_pokazivac

Initial Description
Bilioteka za rješenje pomoču pokazivača.

Initial Title
Strukture_biblioteka_pokazivac

Initial Tags

                                

Initial Language
C++