its so complicated
i cant see the general way
Code:
Node* what2(Node *head){
	Node *temp, *prev, *next, *prevmax, *newhead;	
	while(head->next){
		prevmax = prev = next = NULL;
		for(temp=head; temp; temp=temp->next){
			printf("%d ", temp->value);
			next = temp -> next;
			if((!prev || prev->value < temp->value) && 
(!next || temp->value > next->value)){
				if(! prevmax )
					newhead = temp;
				else
					prevmax->next= temp;
				prevmax = temp;
			}
			if(prev && prev!=prevmax)
				free(prev);
			prev = temp;
		}
		prevmax -> next = NULL;
		head = newhead;
		putchar('\n');
	}
	return head;
}