void DancePartner(DataType dancer[], int num)
{
LinkQueue maleQueue = SetNullQueue_Link();
LinkQueue femaleQueue = SetNullQueue_Link();
for (int i = 0; i < num; i++)
{
if (dancer[i].sex == 'M')
{
EnQueue_link(maleQueue, dancer[i]);
}
else if (dancer[i].sex == 'F')
{
EnQueue_link(femaleQueue, dancer[i]);
}
}
while (!IsNullQueue_link(maleQueue) && !IsNullQueue_link(femaleQueue))
{
DataType male = FrontQueue_link(maleQueue);
DataType female = FrontQueue_link(femaleQueue);
printf("%s %s\n", female.name, male.name);
DeQueue_link(maleQueue);
DeQueue_link(femaleQueue);
}
printf("\n");
if (!IsNullQueue_link(maleQueue))
{
DataType single = FrontQueue_link(maleQueue);
printf("%s\n", single.name);
}
if (!IsNullQueue_link(femaleQueue))
{
DataType single = FrontQueue_link(femaleQueue);
printf("%s\n", single.name);
}
}
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44