分析:此题关键在于找到最大元素所在的前驱结点。
status_code remove_max_elem_llist( link_list * lst, elem_type * e )
{
status_code res = Success;
node_ptr h = *lst, p = h, pre_max = p;
int max_v = -1000;
while( p->next != NULL )
{
if( p->next->data > max_v )
{
pre_max = p;
max_v = p->next->data;
}
p = p->next;
}
p = pre_max->next;
*e = p->data;
pre_max->next = p->next;
free( p );
return res;
}