From: Use of http://apps.hi.baidu.com/share/detail/16127627STL queue # include <iostream>
# Include <queue>
# Include <assert. h>
/*
Header files: # include <stdlib. h> or # include <cstdlib> +
# Include <queue>
Detailed usage:
Define the queue variable <type> m
Check whether the null sample M. Empty () is 1, not 0;
Add M. Push () to the end of an existing element ()
Output the number of existing elements M. Size ()
Display the first element M. Front ()
Show the last element M. Back ()
Clear the first element M. POP ()
*/
Using namespace STD;
Int _ tmain (INT argc, _ tchar * argv [])
{
Queue <int> myq;
Cout <"is the queue empty now? "<Myq. Empty () <Endl;
For (INT I = 0; I <10; I ++)
{
Myq. Push (I );
}
For (INT I = 0; I <myq. Size (); I ++)
{
Printf ("myq. Size (): % d/N", myq. Size ());
Cout <myq. Front () <Endl;
Myq. Pop ();
}
System ("pause ");
Return 0;
}
Output result:
Is the queue empty now? 1
Myq. Size (): 10
0
Myq. Size (): 9
1
Myq. Size (): 8
2
Myq. Size (): 7
3
Myq. Size (): 6
4
Press any key to continue...