标签:
已知链表的头节点为head,写一个函数把链表逆序。
void reserve(list_node* head){
     if(head == NULL)
       return 0;
     list_node* p = head;
     list_node* q = p->next;
     list_node* r = NULL;
     while(q){
        r = q->next;
        q->next = p;
        p = q;
        q = r;
   }
      head->next == NULL;
      head = p;
}
找出单链表的中间节点
list_node* findMiddleNode(list_node* head){
   if(head == NULL || head->next == NULL){
       return 0;
    }
    list_node* p = head;
    list_node* q = head; 
   while(q->next!=NULL&&q->next->next!=NULL){
    p = p->next;
    q = q ->next->next;
   }
    return p;
}
标签:
原文地址:http://www.cnblogs.com/zqlmmd/p/5469855.html