注册 登录
编程论坛 C# 论坛

C#数据结构链表排序,如何排序?

冷锋2048 发布于 2016-05-17 12:07, 1887 次点击
  //链表排序
        public void paixu(ref LinkedList a)//有参数链表a的,参数在main函数

        {
            Node tempNode = a.head;
            for (int i = 0; i < count; i++)
            {
                for (int j = 0; j < count; j++)
                {
                    if ((int)tempNode.item > (int)tempNode.next.item  )//这行报错
                    {
                        int b = 0, c = 0, d = 0;
                        c = (int)tempNode.next.item;
                        b = (int)tempNode.item;
                        d = c;
                        c = b;
                        b = d;
                    }
                    tempNode = tempNode.next;
                }
            }
        }
然后我就没头绪了....不知道在哪里修改
0 回复
1