Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
WeekD
//g++ 7.4.0 ////////////////////////////////////////////////////////////////////////// // WeekD: application of Circular Queue //this code is created by Rezaul Hoque on August 30,2022; //contact:jewelmrh@yahoo.com;Dhaka,Bangladesh;https://rezaulhoque.wordpress.com,https://hoquestake.blogspot.com //note: codes shared by Rezaul Hoque on rextester are not for sale; they are created and shared to facilitate the algorithm learning process; many like Hoque use this platform to practice programming ;Rezaul hopes his contribution helps others to fine tune their learning; ///////////////////////////////////////////////////////////////////////////// #include <iostream> #include <string> using namespace std; class WeekD { std::string s; public: WeekD(){} WeekD(std::string a){s=a;} ~WeekD(){} std::string getS(){return s;} }; template <class T> class Q{ public: Q(int s=100) : size(s+1) , first (-1),last (-1) { data = new T[size ];} ~Q(){ delete [] data;} int isEmpty() const { if(first==-1) return 1; else return 0; } int isFull() const { if(first==0 && last == size-1) {return 1;} if(first==last+1) {return 1;} return 0; } void enqueue(const T& x){ if(isFull()){ std::cout<<"Queue is full\n";} else { if(first==-1) first=0; last=(last+1)%size; data [last]=x; } } T dequeue(){ T x; if(isEmpty()){ std::cout<<"Queue is empty. \n"; return -1; } else { x= data[first ]; if(first == last) { first = -1; last=-1; } else { first =( first +1)%size;} return x; } } int size, first, last; T* data; }; int main () { WeekD Sat("Saturday: Do some house cleaning!\n"); WeekD Sun("Sunday: Relax,Eat,Sleep,Read,Repeat!\n"); WeekD Mon("Monday: Code,Code and Code!\n"); WeekD Tue("Tuesday: Walk,Walk and Walk!\n"); WeekD Wed("Wednesday: Attend the invitation!\n"); WeekD Thu("Thursday: Walk, Code,House cleaning,Read!\n"); WeekD Fri("Friday: Read,Walk,Code,Evaluate!\n"); Q<WeekD> q1(7); q1.enqueue(Sat); q1.enqueue(Sun); q1.enqueue(Mon); q1.enqueue(Tue); q1.enqueue(Wed); q1.enqueue(Thu); q1.enqueue(Fri); std::cout<<"Agendas For The Week:\n"; for(int i=q1.first;i<=q1.last;i++){ cout<<q1.data[i].getS(); } return 0; }
run
|
edit
|
history
|
help
0
vertical sum
ახარისხება~ფინალური
ContainerVector2
segmentedSieveR
Sort an array of 0s, 1s and 2s
cppPyClassInit
Building squares using smallest amount of matches
Counting top students
Teatime Snack
sgfsfdgsfd