利用链队列解决舞伴配对问题，c语言实现

① 初始化Mdancers队列和Fdancers队列。
② 反复循环，依次将跳舞者根据其性别插入Mdancers队列或Fdancers队列。
③ 当Mdancers队列和Fdancers队列均为非空时，反复循环，依次输出男女舞伴的姓名。
④ 如果Fdancers队列非空，则输出Fdancers队列的队头女士的姓名。
⑤ 如果Mdancers队列非空，则输出Mdancers队列的队头男士的姓名。

#include<stdio.h>
#include<stdlib.h>

typedef struct
{
char name[20];
char sex;
} DataType;

struct Node {
DataType	  data;
struct Node*  next;
};
typedef struct Node  *PNode;
struct Queue
{
PNode		f;
PNode		r;
};
{
if (lqueue != NULL)
{
lqueue->f = NULL;
lqueue->r = NULL;
}
else
printf("Alloc failure! \n");
return  lqueue;
}

{
return (lqueue->f == NULL);
}

{
PNode  p;
p = (PNode)malloc(sizeof(struct Node));
if (p == NULL)
printf("Alloc failure!");
else {
p->data = x;
p->next = NULL;
if (lqueue->f == NULL)
{
lqueue->f = p;
lqueue->r = p;
}
else
{
lqueue->r->next = p;
lqueue->r = p;
}
}
}
{
struct Node  * p;
if (lqueue->f == NULL)
printf("It is empty queue!\n ");
else
{
p = lqueue->f;
lqueue->f = lqueue->f->next;
free(p);
}
}
{
if (lqueue->f == NULL)
{
printf("It is empty queue!\n");
}
else
return (lqueue->f->data);
}

void DancePartner(DataType dancer[], int num)
{
int i;
for (i = 0; i < num; i++)
{
if(dancer[i].sex=='M')
{
}
if(dancer[i].sex=='F')
{
}
}
{
}
printf("\n");
else
}

int main()
{
int i;
DataType dancer[9];
for( i = 0; i < 9; i++)
scanf("%s %c", dancer[i].name, &dancer[i].sex);
DancePartner(dancer, 9);
return 0;
}

03-22
03-15 3039

12-16 1589
09-27 781
12-22 2754
11-12 2752
09-29 9229
11-26 929
11-09 1928