Before in article C++ Stack Example Rearranging RailRoad Cars 火车车厢重排问题 we use three stacks to solve the "Rearranging RailRoad Cars" problem. In this article, we will use two queues to solve the problem.
The Whole Code
// RailRoadQueue.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
#include <queue>
using namespace std;
template <class T>
void PrintfNum(T a[], const int