예제 #1
0
        //-------------------------------------------------------------------------------------------------------------

        public void QuickSort(LinkedListSV <SinhVien> l)
        {
            LinkedListSV <SinhVien> l1 = new LinkedListSV <SinhVien>();
            LinkedListSV <SinhVien> l2 = new LinkedListSV <SinhVien>();

            LinkedListSV <SinhVien> .Node tag, p;
            if (l.pHead == l.pTail)
            {
                return;
            }

            tag       = l.pHead;
            l.pHead   = l.pHead.pNext; // cap nhat lai l.head
            tag.pNext = null;          // co lap tag
            while (l.pHead != null)
            {
                p       = l.pHead;
                l.pHead = l.pHead.pNext;
                p.pNext = null;
                if (p.data.DiemTB >= tag.data.DiemTB)
                {
                    l1.AddHead(p.data);
                }
                else
                {
                    l2.AddHead(p.data);
                }
            }
            QuickSort(l1); // goi de qui sap xep l1, l2
            QuickSort(l2);
            if (l1.pHead != null)
            {                              // l1 k rong
                l.pHead        = l1.pHead; // lay head cua l1 gan cho head cua l;
                l1.pTail.pNext = tag;
            } // l1 rong
            else
            {
                l.pHead = tag;
            }
            tag.pNext = l2.pHead;
            if (l2.pHead != null)
            {
                l.pTail = l2.pTail;
            }
            else
            {
                l.pTail = tag;
            }
        }
예제 #2
0
        private void HienthidanhsachSinhVienTBYeu()
        {
            NapDaTaSVTBYeu();
            QuickSort(CSDL_SV);
            lvThongTinTimKiem.Items.Clear();
            LinkedListSV <SinhVien> .Node NodeSP = CSDL_SV.pHead;

            while (NodeSP != null)
            {
                ListViewItem lviSV = new ListViewItem(NodeSP.data.MaSV);
                lviSV.SubItems.Add((NodeSP.data.TenSV));
                lviSV.SubItems.Add(NodeSP.data.GioiTinh.ToString());
                lviSV.SubItems.Add(NodeSP.data.NamSinh.ToString());
                lviSV.SubItems.Add(NodeSP.data.DiemToan.ToString());
                lviSV.SubItems.Add(NodeSP.data.DiemLy.ToString());
                lviSV.SubItems.Add(NodeSP.data.DiemHoa.ToString());
                lviSV.SubItems.Add(NodeSP.data.DiemTB.ToString());
                lviSV.SubItems.Add(NodeSP.data.MaLop);
                lvThongTinTimKiem.Items.Add(lviSV);
                NodeSP = NodeSP.pNext;
            }
        }