Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Dequeue Using STL List
/* * C++ Program to Implement Dequeue using List Stl */ #include <iostream> #include <list> #include <string> #include <cstdlib> using namespace std; int main() { int myints[] = {5, 6, 3, 2, 7}; list<int> l, l1 (myints, myints + sizeof(myints) / sizeof(int)); list<int>::iterator it; int choice, item; while (1) { cout<<"\n---------------------"<<endl; cout<<"Dequeue using STL List"<<endl; cout<<"\n---------------------"<<endl; cout<<"1.Insert Element at the Front of Dequeue"<<endl; cout<<"2.Insert Element at the End of Dequeue"<<endl; cout<<"3.Delete Element from the Front of Dequeue"<<endl; cout<<"4.Delete Element from the End of Dequeue"<<endl; cout<<"5.Front Element of Dequeue"<<endl; cout<<"6.Last Element of the Dequeue"<<endl; cout<<"7. Elements of Dequeue are:"<<endl; cout<<"Enter your Choice: "; cin>>choice; switch(choice) { case 1: cout<<"Enter value to be inserted at the front: "; cin>>item; l.push_front(item); break; case 2: cout<<"Enter value to be inserted at the end: "; cin>>item; l.push_back(item); break; case 3: item = l.front(); l.pop_front(); cout<<"Element "<<item<<" deleted"<<endl; break; case 4: item = l.back(); l.pop_back(); cout<<"Element "<<item<<" deleted"<<endl; break; case 5: cout<<"Front Element of the Dequeue: "; cout<<l.front()<<endl; break; case 6: cout<<"Last Element of the Dequeue: "; cout<<l.back()<<endl; break; case 7: cout<<"Elements of the List: "; for (it = l.begin(); it != l.end(); it++) cout<<*it<<" "; cout<<endl; break; default: cout<<"Wrong Choice"<<endl; } } return 0; }
run
|
edit
|
history
|
help
0
auto decltype - Return Type Decltype
Operators overloading
Error with move capture of a const ref in a lambda function
VC++ windows exception
hangman
throwing std::function on MSVC is dangerous
CommandQueue
problem_binary_4
For NULL-embedded strings, CStringT::Find() produces what you may not expect
dump_own_process.cpp