JJY

C#单链表翻转

做反转之前,应该先判断该单链表是否有环,判断方法参见

http://www.cnblogs.com/jiajinyi/archive/2010/01/27/1657845.html

 

        static void Reverse(SingleLinkNode node)
        {
            SingleLinkNode temp = null, current = null;
            while (node != null)
            {
                temp = current;
                current = node;
                node = node.NextNode;
                current.NextNode = temp;
            }
        }

posted on 2010-01-20 11:38  MikeJia  阅读(470)  评论(0编辑  收藏  举报

导航