链表逆序

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;
  }
}

  

posted on 2017-05-08 20:47  冰狼舞  阅读(60)  评论(0编辑  收藏  举报