Posted By

ivarbanas on 12/03/11


Tagged


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

ivarbanas


red_pokazivac.h


 / Published in: C++
 

Implementacija pokazivac

  1. #include <cstdlib>
  2. #include <iostream>
  3. using namespace std;
  4. struct tpopis{
  5. int redbr;
  6. int x;
  7. int y;
  8. int z;
  9. };
  10.  
  11. struct mid{
  12. tpopis popis;
  13. mid *sljedeci;
  14. };
  15.  
  16. struct bot{
  17. mid *front, *rear;
  18. };
  19.  
  20. void initq(bot *red){
  21. red->front=(mid*)malloc(sizeof(mid));
  22. red->front->sljedeci=NULL;
  23. red->rear=red->front;
  24. cout<<"Red je inicijaliziran!"<<endl;
  25. };
  26.  
  27. bool isemptyq(bot *red){
  28. if(red->front==red->rear) return true;
  29. else return false;
  30. };
  31.  
  32. tpopis frontq(bot *red){
  33. if(isemptyq(red)) cout<<"Red je prazan!";
  34. else return (red->front->sljedeci->popis);
  35. };
  36.  
  37. void enqueueq(tpopis x,bot *red){
  38. mid *pom;
  39. pom=new mid;
  40. pom->popis=x;
  41. pom->sljedeci=NULL;
  42. red->rear->sljedeci=pom;
  43. red->rear=pom;
  44. };
  45.  
  46. void dequeueq(bot *red){
  47. mid *pom;
  48. if(isemptyq(red))
  49. cout<<"Red je prazan!";
  50. else{
  51. pom=red->front;
  52. red->front=red->front->sljedeci;
  53. free(pom);
  54. }};

Report this snippet  

You need to login to post a comment.