Answers for "print queue c++"

C++
0

print queue c++

#include <queue>
#include <iostream>

void print_queue(std::queue q)
{
  while (!q.empty())
  {
    std::cout << q.front() << " ";
    q.pop();
  }
  std::cout << std::endl;
}

int main()
{
  std::queue<int> q;
  for (auto i : {1,2,3,7,4,9,7,2,4}) q.push(i);
  print_queue(q);
}
Posted by: Guest on January-21-2021

Browse Popular Code Answers by Language