Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
CqueueArray
//g++ 5.4.0 #include <iostream> using namespace std; class queue { int q[10]; int f,r; public: queue() { f=-1; r=f; } void insert(int x) { if(isempty()) { f=r=0; q[r]=x; } else if(isfull()) {cout<<"full";} else { r=(r+1)%10; //size q[r]=x; } } void del() { if(isempty()) {cout<<"empty";} else { if(f==r) { f=r=-1; } else { f=(f+1)%10; } } } bool isempty() { if(f==-1) return true; return false; } bool isfull() { if(f==(r+1)%10) return true; return false; } void display() { if(f<=r) { for(int i=f;i<=r;i++) cout<<q[i]<<" "; } else { for(int i=f;i<=9;i++) cout<<q[i]<<" "; for(int i=0;i<=r;i++) cout<<q[i]<<" "; } } }; int main() { queue q; q.insert(1); q.insert(2); q.insert(3); q.insert(4); q.insert(5); q.insert(6); q.insert(7); q.insert(7); q.insert(7); q.insert(10); q.del(); q.insert(127);//*/ q.display(); q.del(); /* q.del(); q.del(); q.del(); q.del(); q.del(); q.del(); q.del(); q.del(); q.del(); q.del(); */ q.del(); q.del(); q.display(); }
run
|
edit
|
history
|
help
0
Sample Code from Scott Meyer's Blog
Org
C++ Car Racing game framework
ulib
is_num_palindrom
Rotate90
Eratosfen final
Gauss 4x4
code_chef
Best way for getting more precision no.