fork download
  1. //
  2. // main.cpp
  3. // Queue
  4. //
  5. // Created by Himanshu on 03/10/21.
  6. //
  7.  
  8.  
  9. #include <iostream>
  10. #include <queue>
  11. using namespace std;
  12.  
  13. int main () {
  14.  
  15. queue<int> qu;
  16.  
  17. cout<<"Enqueue(x) {10, 20, 30, 40, 50}"<<endl;
  18. qu.push(10);
  19. qu.push(20);
  20. qu.push(30);
  21. qu.push(40);
  22. qu.push(50);
  23.  
  24. cout<<"Queue-Empty(): ";
  25. if (qu.empty()) {
  26. cout<<"Queue is empty"<<endl;
  27. } else {
  28. cout<<"Queue is not empty"<<endl;
  29. }
  30.  
  31. cout<<"Dequeue elements..."<<endl;
  32. while (!qu.empty()) {
  33. cout<<qu.front()<<" ";
  34. qu.pop();
  35. }
  36. cout<<endl;
  37.  
  38. cout<<"Queue-Empty(): ";
  39. if (qu.empty()) {
  40. cout<<"Queue is empty"<<endl;
  41. } else {
  42. cout<<"Queue is not empty"<<endl;
  43. }
  44.  
  45. return 0;
  46. }
  47.  
  48.  
Success #stdin #stdout 0.01s 5456KB
stdin
Standard input is empty
stdout
Enqueue(x) {10, 20, 30, 40, 50}
Queue-Empty(): Queue is not empty
Dequeue elements...
10 20 30 40 50 
Queue-Empty(): Queue is empty