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) ;
}
}