#include<stdio.h>
#include<malloc.h>

#define MAXSIZE 100

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

typedef struct
{
	person dancer[3];
person *base;
int front;
int rear;
}Queue;


void Initqueue(Queue *p)
{
p->base=(person *)malloc(MAXSIZE*sizeof(person));
if(!p->base) exit(-1);
p->front=p->rear=0;

}

void EnQueue(Queue *p,person s)
{
if((p->rear+1)%MAXSIZE==p->front)
exit(-1);
p->base++;
p->base[p->rear]=s;
p->rear=(p->rear+1)%MAXSIZE;
}

void DeQueue(Queue *p,person s)
{
if(p->front==p->rear) exit(-1);
s=p->base[p->front];
p->front=(p->front+1)%MAXSIZE;
}

void dancers(person dancer[])
{
	int i;
	int a=1;
	person p;
	Queue Mdancers;
Queue Fdancers;

	Initqueue(&Mdancers);
    Initqueue(&Fdancers);
	for(i=0;i<3;i++)
	{
	p=dancer[i];
	if(p.sex=='F') 
	{
		EnQueue(&Fdancers,p);
        printf("%s\n",p.name);
	}
	else 
	{
		EnQueue(&Mdancers,p);
        printf("%s\n",p.name);
	}

	}
printf("舞伴组合为\n");

while(a=1)
{
DeQueue(&Fdancers,p);
printf("%s",p.name);
DeQueue(&Mdancers,p);
printf("%s\n",p.name);
}
}


int main()
{
	
int i;
person p;
person dancer[3];
for(i=0;i<3;i++) 
{ 
printf("请输入姓名");
scanf("%s",dancer[i].name); 
getchar(); 
printf("请输入性别");
scanf("%c",&dancer[i].sex); 
}

dancers(&dancer[0]);

return 0;
}