Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdlib>
- #include <iostream>
- #include <queue>
- #include <conio.h>
- using namespace std;
- struct element
- {
- string wart;
- int piorytet;
- };
- class FIFO
- {
- public:
- int max=100;
- element *tablica;
- int glowa;
- int ogon;
- FIFO(){
- glowa=ogon=0;
- tablica==new element[max];
- }
- bool empty(){
- if(glowa==ogon) return true;
- else return false;
- }
- bool attach(int el)
- {
- if(empty())
- {
- ogon=(ogon+1)%max;
- tablica->wart[ogon]=el;
- }
- else{
- if((ogon+1)%max==glowa) return false;
- else
- {
- ogon=(ogon+1)%max;
- tablica->wart[ogon]=el;
- }
- return true;
- }
- }/*
- bool detach();
- element front()
- {
- return element[glowa];
- }
- bool empty();
- */
- };
- int main()
- {
- FIFO fifo = new FIFO();
- for(int i=0;i<10;i++) if(fifo.attach(i))fifo.attach(i);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement