DSA QUEUE CODE
parent
ec8bdb7c84
commit
80359f466f
|
@ -0,0 +1,31 @@
|
|||
#include <iostream>
|
||||
#include <queue>
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main() {
|
||||
|
||||
// create a queue of string
|
||||
queue<string> animals;
|
||||
|
||||
// push elements into the queue
|
||||
animals.push("Cat");
|
||||
animals.push("Dog");
|
||||
|
||||
cout << "Queue: ";
|
||||
|
||||
// print elements of queue
|
||||
// loop until queue is empty
|
||||
while(!animals.empty()) {
|
||||
|
||||
// print the element
|
||||
cout << animals.front() << ", ";
|
||||
|
||||
// pop element from the queue
|
||||
animals.pop();
|
||||
}
|
||||
|
||||
cout << endl;
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue