首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

队列-数组存储结构及其操作算法的实现-舞伴有关问题

2013-03-16 
队列-----数组存储结构及其操作算法的实现-----舞伴问题//?è°é?êìa#includeiostream#include queue.hu

队列-----数组存储结构及其操作算法的实现-----舞伴问题

//?è°é?êìa#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;}


热点排行