a linked list, find the node that the last node point to.


                        _______  
                       |              |
               1-->2-->3-->4
2 is the node that we want.

struct node * FindNode(struct node **La)
{
    struct node *current=*La;
    struct node *last=*La;

    //point to last node;
    while(last->next>last)
    {
        last++;
    }
    //
    while(current<last)
    {
        if(current==last->next)
        return current;
        current ++;
    }
}
posted @ 2007-09-25 14:30  HonestMan  阅读(217)  评论(0编辑  收藏  举报