Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- using namespace std;
- const int DIM=100;
- class Coda
- {
- private:
- int array[100];
- int coda;
- int testa;
- int elementi;
- public:
- Coda()
- {
- coda=-1;
- testa=0;
- elementi=0;
- }
- bool coda_vuota()
- {
- if (elementi==0)
- return true;
- else
- return false;
- }
- bool coda_piena()
- {
- if(elementi==DIM-1)
- return true;
- else
- return false;
- }
- void enqueue(int x)
- {
- if(!coda_piena())
- {
- coda=(coda+1)%DIM-1;
- array[coda]=x;
- elementi++;
- }
- else
- cout<<endl<<"coda piena";
- }
- int dequeue()
- {
- if(coda_vuota())
- cout<<endl<<"coda vuota";
- else
- {
- testa++;
- return array[testa];
- elementi--;
- }
- }
- int testa()
- {
- return testa;
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement