Posted By


redops28 on 11/20/10

Tagged


Statistics


Viewed 44 times
Favorited by 0 user(s)

SP_Z3_red_polje.h_jz.cpp


/ Published in: C++
Save to your folder(s)



Copy this code and paste it in your HTML
  1. #include <iostream>
  2. using namespace std;
  3. struct red {
  4. tklijent klijent[1000];
  5. int front,rear;
  6. };
  7.  
  8. int AddOne(int n) {
  9. return((n+1)%1000);
  10. }
  11.  
  12. tklijent FrontQ(red *Q) {
  13. if (AddOne(Q->rear)==Q->front) {
  14. cout << "Red je prazan" << endl;
  15.  
  16. exit(0);
  17. }
  18. else
  19. return(Q->klijent[Q->front]);
  20. }
  21.  
  22. void EnQueueQ(tklijent x,red *Q) {
  23. if (AddOne(AddOne(Q->rear))==Q->front) {
  24. cout << "Red je pun" << endl;
  25.  
  26. exit(0);
  27. }
  28. else {
  29. Q->rear=AddOne(Q->rear);
  30. Q->klijent[Q->rear]=x;
  31. }
  32. }
  33.  
  34. void DeQueueQ(red *Q) {
  35. if (AddOne(Q->rear)==Q->front) {
  36. cout << "Red je prazan" << endl;
  37.  
  38. exit(0);
  39. }
  40. else
  41. Q->front=AddOne(Q->front);
  42. }
  43.  
  44. void InitQ(red *Q) {
  45. Q->rear=999;
  46. Q->front=0;
  47. }
  48.  
  49. int IsEmptyQ(red *Q) {
  50. if (AddOne(Q->rear)==Q->front)
  51. return(-1);
  52. else
  53. return(0);
  54. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.