(1) any flight can be brought to the front of the queue ready for deleting(landing)
(2) any flight can be diverted to the back of the queue for another airport if the first airport is busy or on runway closed due to an accident.
(3)in the flight ID, there can only be one unique letter, for example A, a, B,b, we cannot have A,A, but we can have A,a
>the following three questions
You only have two questions.
>Any flight can be brought to the front of the queue ready for deleting
Since your queue is implemented with a linked list, you can easily splice out an item and replace it elsewhere:
these codes might help, i can't make it work
void moveToFront ( queue& q, const char data )
{
nodePtr item;
// Check to see if it's already at the front
if ( data == q.front->data )
return;
// Find the item
for ( nodePtr it = q.front; it->next != 0; it = it->next ) {
if ( data == it->next->data ) {
item = it->next;
it->next = item->next;
break;
}
}
// Move to front
item->next = q.front;
q.front = item;
}
>In the flight ID, there can only be one unique letter
For each new ID, traverse the queue and make sure it doesn't already exist:
bool isUnique ( queue& q, const char data )
{
for ( nodePtr it = q.front; it != 0; it = it->next ) {
if ( data == it->data )
return false;
}
return true;
}
Code removed at OP's request
Code removed at OP's request
Code tags added and ugly ass colors removed. -Narue