手机版

实验08 队列(循环队列)的表示和实现(3)

时间:2025-07-06   来源:未知    
字号:

【附录----源程序】

test3_2.cpp

#include<iostream.h>

#include<stdlib.h>

typedef char ElemType;

#include"SeqQueue.h"

void partner(Queue F,Queue M);

struct Dancer{

char name;

char sex;

};

void main()

{

Queue F,M;

InitQueue(F);

InitQueue(M);

partner(F,M);

ClearQueue(F);

ClearQueue(M);

}

void partner(Queue F,Queue M)

{

Dancer D;

cout<<"请输入跳舞者的姓名和性别:"<<endl;

cin>>>>D.sex;

while(!='#'&&D.sex!='#'){

if(D.sex=='F'||D.sex=='f')

EnQueue(F,);

else if(D.sex=='M'||D.sex=='m')

EnQueue(M,);

cin>>>>D.sex;

}

cout<<"配对的舞伴是:"<<endl;

while(!EmptyQueue(F)&&!EmptyQueue(M))

cout<<OutQueue(F)<<' '<<OutQueue(M)<<endl;

if(!EmptyQueue(F)){

cout<<"女队还有人等待下一轮舞曲。"<<endl;

cout<<OutQueue(F)<<"将是下一轮得到舞伴的第一人。"<<endl; }

if(!EmptyQueue(M)){

cout<<"男队还有人等待下一轮舞曲。"<<endl;

cout<<OutQueue(M)<<"将是下一轮得到舞伴的第一人。"<<endl; }

实验08 队列(循环队列)的表示和实现(3).doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
×
二维码
× 游客快捷下载通道(下载后可以自由复制和排版)
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能出现无法下载或内容有问题,请联系客服协助您处理。
× 常见问题(客服时间:周一到周五 9:30-18:00)