Posted By

Sostar_Martin on 12/03/11


Tagged

red sp3 biblioteka


Versions (?)

red_pokazivac.h


 / Published in: C++
 

Martin Sostar

  1. #include <cstdlib>
  2. #include <iostream>
  3. #include <time.h>
  4.  
  5. using namespace std;
  6.  
  7.  
  8. struct pac
  9. { int rb,a,b,c;
  10.  
  11. };
  12.  
  13. struct t{
  14. pac popis;
  15. t *sljedeci;
  16. };
  17.  
  18. struct p{
  19. t *front, *rear;
  20. };
  21.  
  22.  
  23. void InitQ(p *red){
  24. red->front=(t*)malloc(sizeof(t));
  25. red->front->sljedeci=NULL;
  26. red->rear=red->front;
  27. cout<<"Red je inicijaliziran"<<endl;
  28. };
  29.  
  30. bool IsEmptyQ(p *red){
  31. if(red->front==red->rear) return true;
  32. else return false;
  33. };
  34.  
  35. void EnQueueQ(pac x,p *red){
  36. t *pom;
  37. pom=new t;
  38. pom->popis=x;
  39. pom->sljedeci=NULL;
  40. red->rear->sljedeci=pom;
  41. red->rear=pom;
  42. };
  43.  
  44. void DeQueueQ(p *red){
  45. t *pom;
  46. if(IsEmptyQ(red)) cout<<"red je prazan";
  47. else{
  48. pom=red->front;
  49. red->front=red->front->sljedeci;
  50. delete(pom);
  51. }
  52. };
  53.  
  54. pac FrontQ(p *red){
  55. if(IsEmptyQ(red)) cout<<"red je prazan";
  56. else return (red->front->sljedeci->popis);
  57. };
  58.  
  59. clock_t vrijeme1,vrijeme2;
  60. double razlika;
  61. double vrijeme_pocetak(){
  62. vrijeme1=clock();
  63. return (double)vrijeme1;
  64. };
  65. double vrijeme_kraj(){
  66. vrijeme2=clock();
  67. return (double)vrijeme2;
  68. };
  69. double vrijeme_proteklo(){
  70. razlika=vrijeme2-vrijeme1;
  71. return razlika;
  72. };

Report this snippet  

You need to login to post a comment.