[Cpp] // file: queue. h # ifndef _ Queue_H_INCLUDE _ # define N 10002 # include <cstdio> template <class T> class Queue {public: Queue (): frount (1 ), rear (1) {} void push (T t); void pop (); T front (); bool empty (); private: int frount, rear; t q [N] ;}; template <class T> bool Queue <T >:: empty () {if (frount = rear) return true; else return false ;} template <class T> T Queue <T>: front (){ If (! Empty () return Q [frount]; else {printf ("Empty! \ N ") ;}}template <class T> void Queue <T >:: pop () {if (! Empty () frount ++; else printf ("Empty! \ N ");} template <class T> void Queue <T>: push (T t) {Q [rear] = t; rear ++ ;} # endif/_ STACK_H_INCLUDE _ [cpp] // ******â # include <iostream> # include "queue. h "using namespace std; struct node {char name [20]; char sex ;}; int main () {Queue <node> m, w; int n; struct node x; cin> n; while (n --) {cin> x. name; cin> x. sex; if (x. sex = 'W') w. push (x); else if (x. sex = 'M') m. push (x); else;} while (! W. empty ()&&! M. empty () {cout <w. front (). name <"--" <m. front (). name <endl; w. pop (); m. pop ();} if (w. empty () {printf ("There are men still waiting! \ N ");} else if (m. empty () {printf (" There are women still waiting! \ N ");} else printf (" There is no person waiting! \ N "); return 0 ;}