1. 程式人生 > >鏈表逆序

鏈表逆序

class private sha cnblogs null oid void clas highlight

private void ListResverse(ListNode head)
{
  ListNode cur,next;
  if(head == null||head.next == null)
    return;
  cur = head.next;
  while(cur.next!=null)
  {
    next = cur.next;
    cur.next = next.next;
    next.next = cur;
    head.next = next;
  }
}

  

鏈表逆序