Posted By


bagrancar on 12/03/11

Tagged


Statistics


Viewed 91 times
Favorited by 0 user(s)

Strukture_biblioteka_polje


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

Biblioteka za rješenje pomoču polja.


Copy this code and paste it in your HTML
  1. #include <cstdlib>
  2. #include <iostream>
  3. using namespace std;
  4. struct tpopis
  5. { int rb;
  6. int x;
  7. int y;
  8. int p;
  9. };
  10. struct r{
  11. tpopis popis[10000];
  12. int front, rear;
  13. };
  14.  
  15. int addone(int i){
  16. return ((i+1)%10000);
  17. };
  18.  
  19. void initq(r *red){
  20. red->front=0;
  21. red->rear=9999; //zadnji el polja
  22. cout<<"Inicijaliziranje reda!!"<<endl;
  23. };
  24.  
  25. bool isemptyq(r *red){
  26. if(addone(red->rear)==red->front) return true;
  27. else return false;
  28. };
  29.  
  30. void enqueueq(tpopis x, r *red){
  31. if(addone(addone(red->rear))==(red->front)) cout<<"Red je trenutno pun!";
  32. else {
  33. red->rear=addone(red->rear);
  34. red->popis[red->rear]=x;
  35. }
  36. };
  37.  
  38. void dequeueq(r *red){
  39. if(isemptyq(red)) cout<<"Red je trenutno prazan!";
  40. else red->front=addone(red->front);
  41. };
  42.  
  43. tpopis frontq(r *red){
  44. if(isemptyq(red)) cout<<"Red je trenutno prazan!";
  45. else return (red->popis[red->front]);
  46. };

URL: www.snipplr.com/strukture_biblioteka_polje

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.