Advertisement
Guest User

Untitled

a guest
Nov 27th, 2015
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.28 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. struct Element{
  6.     string wartosc;
  7.     int priorytet;
  8.    
  9. };
  10.  
  11. class FIFO{
  12.     int max=30;
  13.     Element tab[max];
  14.     int glowa;
  15.     int ogon;
  16.    
  17.     FIFO(){
  18.         glowa=0;
  19.         ogon=0;
  20.     }
  21.    
  22.     bool attach(Element element){
  23.         if(empty()){
  24.             tab[ogon]=element;
  25.             ogon=(ogon+1)%max;
  26.             return true;
  27.         }
  28.         else if((ogon+1)%max==glowa)
  29.             return false;
  30.         else{
  31.             ogon=(ogon+1)%max;
  32.             tab[ogon]=element;
  33.             return true;
  34.         }    
  35.     }
  36.    
  37.     bool detach(){
  38.         if(empty()){
  39.             return false;
  40.         }
  41.         else if((glowa+1)%max==ogon){
  42.             glowa++;
  43.             return false;
  44.         }
  45.         else{
  46.            
  47.         }
  48.        
  49.     }
  50.     bool empty(){
  51.         if(glowa==ogon)
  52.             return true;      
  53.     }
  54.     Element front(){
  55.         if(empty())
  56.             return tab[glowa];
  57.     }
  58.    
  59. };
  60.  
  61. class LIFO{
  62.     int max=30;
  63.     int szczyt;
  64.     Element stos[max];
  65.     LIFO(){
  66.         szczyt=0;
  67.     }
  68.     bool empty(){};
  69.     bool push(el){};
  70.     bool pop(){};
  71.     Element pop(){};
  72. };
  73.  
  74.  
  75. int main(){
  76.     cout << "Hello World!" << endl;
  77.     return 0;
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement