예제 #1
0
 public LinkListFullInfo()
 {
     ID       = type = 0;
     lastName = name = rank = String.Empty;
     minScore = mathScore = literatureScore = englishScore = totalScore = 0;
     Next     = null;
 }
예제 #2
0
        private void FrmStudentRankList_Load(object sender, EventArgs e)
        {
            LinkListFullInfo temp = new LinkListFullInfo();

            //F = temp.loadfullInfo(F);
            F = temp.setStGioi(F);
            F = F.MergeSort(F);

            L = temp.setStKha(L);
            L = L.MergeSort(L);

            datas  = F.change(F);
            datas1 = L.change(L);
            datas.AddRange(datas1);
            foreach (string s in datas)
            {
                textBox1.Text = string.Join(Environment.NewLine, datas);
            }
            using (StreamWriter sw = new StreamWriter("Danhsachhocsinhkhagioi.txt"))
            {
                foreach (string s in datas)
                {
                    sw.WriteLine(s);
                }
            }
        }
예제 #3
0
        public int count(LinkListFullInfo F, int type)
        {
            Console.OutputEncoding = Encoding.Unicode;
            LinkListStudent S = new LinkListStudent();

            S.loadListStudent(S);
            LinkListScore L = new LinkListScore();

            L.loadListScore(L);
            DateTime temp = DateTime.Now;
            int      typeset, dut;
            DateTime birthdate;
            string   rank = null;
            int      count = 0;
            double   mathScore, literatureScore, englishScore, totalScore, minScore;

            while (S != null && L != null)
            {
                typeset         = S.type;
                mathScore       = L.mathScore;
                literatureScore = L.literatureScore;
                englishScore    = L.englishScore;
                minScore        = scoreMin(L.mathScore, L.literatureScore, L.englishScore);
                if (S.type == 1)
                {
                    dut = 2;
                }
                else if (S.type == 2)
                {
                    dut = 1;
                }
                else
                {
                    dut = 3;
                }
                totalScore = L.mathScore + L.literatureScore + L.englishScore + dut;
                birthdate  = S.birthDate;
                if (mathScore == 0 || literatureScore == 0 || englishScore == 0)
                {
                    S = S.Next;
                    L = L.Next;
                    continue;
                }
                if (totalScore < 15 || minScore < 4)
                {
                    rank = "Trượt";
                    if (typeset == type)
                    {
                        count++;
                    }
                }


                S = S.Next;
                L = L.Next;
            }
            return(count);
        }
예제 #4
0
        private List <string> ChangeFile(LinkListFullInfo F)
        {
            List <string>    lines = new List <string>();
            LinkListFullInfo p = F;
            string           string1, string2, string3;

            p = p.Next.Next;
            while (p != null)
            {
                string date = string.Format("{0:dd/MM/yyyy}", p.birthdate);



                //lines.Add(string.Format("{0,-35}{1,-35}{2,-35}","GIAY BAO DIEM", "GIAY BAO DIEM", "GIAY BAO DIEM") + Environment.NewLine);
                if (p.Next != null && p.Next.Next != null)
                {
                    string1 = gender(p.sex);
                    string2 = gender(p.Next.sex);
                    string3 = gender(p.Next.Next.sex);
                    lines.Add(Tab1("GIAY BAO DIEM", 45) + Tab1("GIAY BAO DIEM", 45) + Tab1("GIAY BAO DIEM", 45));
                    lines.Add(Tab1("So bao danh:" + p.ID, 50) + Tab1("So bao danh:" + p.Next.ID, 50) + Tab1("So bao danh:" + p.Next.Next.ID, 50));
                    lines.Add(Tab1((string1 + p.lastName + p.name), 45) + Tab1((string2 + p.Next.lastName + p.Next.name), 45) + Tab1((string3 + p.Next.Next.lastName + p.Next.Next.name), 0));
                    lines.Add(Tab1("Toan:" + p.mathScore, 45) + Tab1("Toan:" + p.Next.mathScore, 50) + Tab1("Toan:" + p.Next.Next.mathScore, 0));
                    lines.Add(Tab1("Van:" + p.literatureScore, 50) + Tab1("Van:" + p.Next.literatureScore, 50) + Tab1("Van:" + p.Next.Next.literatureScore, 50));
                    lines.Add(Tab1("Anh van:" + p.englishScore, 45) + Tab1("Anh van:" + p.Next.englishScore, 45) + Tab1("Anh van:" + p.Next.Next.englishScore, 45));
                    lines.Add(Tab1("Tong diem:" + F.totalScore, 45) + Tab1("Tong diem:" + F.Next.totalScore, 45) + Tab1("Tong diem:" + F.Next.Next.totalScore, 45));
                    lines.Add(Tab1("Xep loai:" + F.rank, 45) + Tab1("Xep loai:" + F.Next.rank, 50) + Tab1("Xep loai:" + F.Next.Next.rank, 40) + Environment.NewLine);
                }
                if (p.Next != null && p.Next.Next == null)
                {
                    string1 = gender(p.sex);
                    string2 = gender(p.Next.sex);
                    lines.Add(Tab1("GIAY BAO DIEM", 45) + Tab1("GIAY BAO DIEM", 45));
                    lines.Add(Tab1("So bao danh:" + p.ID, 50) + Tab1("So bao danh:" + p.Next.ID, 50));
                    lines.Add(Tab1((string1 + p.lastName + p.name), 45) + Tab1((string2 + p.Next.lastName + p.Next.name), 45));
                    lines.Add(Tab1("Toan:" + p.mathScore, 45) + Tab1("Toan:" + p.Next.mathScore, 0));
                    lines.Add(Tab1("Van:" + p.literatureScore, 50) + Tab1("Van:" + p.Next.literatureScore, 50));
                    lines.Add(Tab1("Anh van:" + p.englishScore, 45) + Tab1("Anh van:" + p.Next.englishScore, 45));
                    lines.Add(Tab1("Tong diem:" + F.totalScore, 45) + Tab1("Tong diem:" + F.Next.totalScore, 45));
                    lines.Add(Tab1("Xep loai:" + F.rank, 45) + Tab1("Xep loai:" + F.Next.rank, 45) + Environment.NewLine);
                }
                if (p.Next.Next == null && p.Next == null)
                {
                    string1 = gender(p.sex);
                    lines.Add(Tab1("GIAY BAO DIEM", 45));
                    lines.Add(Tab1("So bao danh:" + p.ID, 50));
                    lines.Add(Tab1(string1 + p.lastName + p.name, 45));
                    lines.Add(Tab1("Toan:" + p.mathScore, 0));
                    lines.Add(Tab1("Van:" + p.literatureScore, 50));
                    lines.Add(Tab1("Anh van:" + p.englishScore, 45));
                    lines.Add(Tab1("Tong diem:" + F.totalScore, 45));
                    lines.Add(Tab1("Xep loai:" + F.rank, 45) + Environment.NewLine);
                }
                p = p.Next.Next;
            }
            return(lines);
        }
예제 #5
0
        public LinkListFullInfo setStGioi(LinkListFullInfo F)
        {
            Console.OutputEncoding = Encoding.Unicode;
            LinkListStudent S = new LinkListStudent();

            S.loadListStudent(S);
            LinkListScore L = new LinkListScore();

            L.loadListScore(L);
            DateTime temp = DateTime.Now;
            int      ID, type, dut;
            DateTime birthdate;
            string   sex;
            string   lastName, name, rank = null;
            double   mathScore, literatureScore, englishScore, totalScore, minScore;

            while (S != null && L != null)
            {
                LinkListFullInfo p = new LinkListFullInfo();
                ID              = S.ID;
                lastName        = S.lastName;
                name            = S.name;
                sex             = S.sex;
                type            = S.type;
                mathScore       = L.mathScore;
                literatureScore = L.literatureScore;
                englishScore    = L.englishScore;
                minScore        = scoreMin(L.mathScore, L.literatureScore, L.englishScore);
                if (S.type == 1)
                {
                    dut = 2;
                }
                else if (S.type == 2)
                {
                    dut = 1;
                }
                else
                {
                    dut = 3;
                }
                totalScore = L.mathScore + L.literatureScore + L.englishScore + dut;
                birthdate  = S.birthDate;
                if (totalScore >= 24 && minScore >= 7)
                {
                    rank = "Giỏi";

                    addFullInfo(p, ID, lastName, name, sex, birthdate, mathScore, literatureScore, englishScore, minScore, totalScore, rank, type);
                    addFull(ref F, p);
                }
                S = S.Next;
                L = L.Next;
            }
            return(F);
        }
예제 #6
0
        public List <string> change(LinkListFullInfo F)
        {
            List <string>    lines = new List <string>();
            LinkListFullInfo p     = F;
            string           date  = string.Format("{0:dd/MM/yyyy}", p.birthdate);

            while (p != null)
            {
                lines.Add(tab(p.ID.ToString(), 3) + tab(p.lastName, 15) + tab(p.name, 10) + tab(p.sex, 3) + tab(date, 12) + "  " + tab(p.mathScore.ToString(), 3) + tab(p.literatureScore.ToString(), 2) + tab(p.englishScore.ToString(), 2) + tab(p.totalScore.ToString(), 2) + " " + tab(p.rank, 3) + " " + p.type);
                p = p.Next;
            }
            return(lines);
        }
예제 #7
0
        public int total(LinkListFullInfo F, int type)
        {
            int total          = 0;
            LinkListFullInfo p = F;

            while (p != null)
            {
                if (p.type == type)
                {
                    total++;
                }
                p = p.Next;
            }
            return(total);
        }
예제 #8
0
        public LinkListFullInfo MergeSortFail(LinkListFullInfo node)
        {
            if (node.Next == null)
            {
                return(node);
            }
            var middle       = GetMiddle(node);
            var nextToMiddle = middle.Next;

            middle.Next  = null;
            node         = MergeSortFail(node);
            nextToMiddle = MergeSortFail(nextToMiddle);
            var sortedLinkedList = MergeFail(node, nextToMiddle);

            return(sortedLinkedList);
        }
예제 #9
0
 public Boolean addFullInfo(LinkListFullInfo p, int ID, string lastName, string name, string sex, /*int age*/ DateTime birthdate, double mathScore, double literatureScore, double englishScore, double minScore, double totalScore, string rank, int type)
 {
     p.ID              = ID;
     p.lastName        = lastName;
     p.name            = name;
     p.sex             = sex;
     p.birthdate       = birthdate;
     p.mathScore       = mathScore;
     p.literatureScore = literatureScore;
     p.englishScore    = englishScore;
     p.minScore        = minScore;
     p.totalScore      = totalScore;
     p.rank            = rank;
     p.type            = type;
     return(true);
 }
예제 #10
0
 public static void addFull(ref LinkListFullInfo L, LinkListFullInfo p)
 {
     if (L == null)
     {
         L = p;
     }
     else
     {
         LinkListFullInfo q = L;
         while (q.Next != null)
         {
             q = q.Next;
         }
         q.Next = p;
     }
 }
예제 #11
0
        private List <string> changedatas(LinkListFullInfo F, double max, ref int count)
        {
            List <string>    lines = new List <string>();
            LinkListFullInfo p     = F;
            string           date  = string.Format("{0:dd/MM/yyyy}", p.birthdate);

            while (p != null)
            {
                if (p.totalScore == max)
                {
                    lines.Add(tab(p.ID.ToString(), 3) + tab(p.lastName, 15) + tab(p.name, 10) + p.sex + "  " + tab(date, 12) + "  " + tab(p.mathScore.ToString(), 3) + tab(p.literatureScore.ToString(), 2) + tab(p.englishScore.ToString(), 2) + tab(p.totalScore.ToString(), 2) + " " + tab(p.rank, 3) + " " + p.type);
                    count++;
                }
                p = p.Next;
            }
            return(lines);
        }
예제 #12
0
 private void Báo_Điểm_Load(object sender, EventArgs e)
 {
     F     = F.loadfullInfo(F);
     datas = Change(F);
     foreach (string s in datas)
     {
         textBox1.Text = string.Join(Environment.NewLine, datas);
     }
     output = ChangeFile(F);
     using (StreamWriter sw = new StreamWriter("BaoDiem.txt"))
     {
         foreach (string s in output)
         {
             sw.WriteLine(s);
         }
     }
 }
예제 #13
0
        private void BtnFind_Click(object sender, EventArgs e)
        {
            int id             = Convert.ToInt32(txtID.Text);
            LinkListFullInfo p = F;

            while (p != null)
            {
                if (p.ID == id)
                {
                    lbLastName.Text = p.lastName;
                    lbName.Text     = p.name;
                    //if (p.sex == true)
                    //{
                    //    lbSex.Text = "Nam";
                    //}
                    //else
                    //{
                    //    lbSex.Text = "Nữ";
                    //}
                    lbSex.Text = p.sex;
                    string   date = string.Format("{0:dd/MM/yyyy}", p.birthdate);
                    int      age;
                    DateTime temp = DateTime.Now;
                    age               = temp.Year - p.birthdate.Year;
                    lbAge.Text        = Convert.ToString(age);
                    lbType.Text       = p.type.ToString();
                    lbMath.Text       = p.mathScore.ToString();
                    lbLiterature.Text = p.literatureScore.ToString();
                    lbEnglish.Text    = p.englishScore.ToString();
                    lbminScore.Text   = p.minScore.ToString();
                    lbtotalScore.Text = p.totalScore.ToString();
                    lbRank.Text       = p.rank;
                    break;
                }
                else
                {
                    p = p.Next;
                }
            }
            if (p == null)
            {
                MessageBox.Show("Error,please check input", "Error", MessageBoxButtons.RetryCancel, MessageBoxIcon.Warning);
            }
        }
예제 #14
0
        public LinkListFullInfo Merge(LinkListFullInfo first, LinkListFullInfo second)
        {
            LinkListFullInfo result = null;

            if (first == null)
            {
                return(second);
            }
            else if (second == null)
            {
                return(first);
            }

            if (first.totalScore > second.totalScore)
            {
                if (first.rank == "Khá" && second.rank == "Giỏi")
                {
                    result      = second;
                    result.Next = Merge(first, second.Next);
                }
                else
                {
                    result      = first;
                    result.Next = Merge(first.Next, second);
                }
            }
            else
            {
                if (first.rank == "Giỏi" && second.rank == "Khá")
                {
                    result      = first;
                    result.Next = Merge(first.Next, second);
                }
                else
                {
                    result      = second;
                    result.Next = Merge(first, second.Next);
                }
            }

            return(result);
        }
예제 #15
0
        private void FrmStudentFail_Load(object sender, EventArgs e)
        {
            LinkListFullInfo temp = new LinkListFullInfo();

            //F = temp.loadfullInfo(F);
            F     = temp.setStTruot(F);
            F     = F.MergeSortFail(F);
            datas = F.change(F);
            foreach (string s in datas)
            {
                textBox1.Text = string.Join(Environment.NewLine, datas);
            }
            using (StreamWriter sw = new StreamWriter("Danhsachhocsinhtruot.txt"))
            {
                foreach (string s in datas)
                {
                    sw.WriteLine(s);
                }
            }
            btnFileout.Enabled = true;
        }
예제 #16
0
        public LinkListFullInfo GetMiddle(LinkListFullInfo node)
        {
            if (node?.Next == null)
            {
                return(node);
            }

            var fastPointer = node.Next;
            var slowPointer = node;

            while (fastPointer != null)
            {
                fastPointer = fastPointer.Next;
                if (fastPointer != null)
                {
                    fastPointer = fastPointer.Next;
                    slowPointer = slowPointer.Next;
                }
            }

            return(slowPointer);
        }
예제 #17
0
        public LinkListFullInfo MergeFail(LinkListFullInfo first, LinkListFullInfo second)
        {
            LinkListFullInfo result = null;

            if (first == null)
            {
                return(second);
            }
            else if (second == null)
            {
                return(first);
            }
            if (first.type == second.type)
            {
                if (first.totalScore > second.totalScore)
                {
                    result      = first;
                    result.Next = MergeFail(first.Next, second);
                }
                else
                {
                    result      = second;
                    result.Next = MergeFail(first, second.Next);
                }
            }
            if (first.type < second.type)
            {
                result      = first;
                result.Next = MergeFail(first.Next, second);
            }
            if (second.type < first.type)
            {
                result      = second;
                result.Next = MergeFail(first, second.Next);
            }


            return(result);
        }
예제 #18
0
        private void BtnShow_Click(object sender, EventArgs e)
        {
            int type           = Convert.ToInt32(textBox2.Text);
            LinkListFullInfo p = new LinkListFullInfo();

            F            = p.loadfullInfo(F);
            count1       = p.total(F, type);
            count2       = p.count(F, type);
            percent1     = Math.Round(percent1, 2);
            percent2     = 100 - percent1;
            percent2     = Math.Round(percent2, 2);
            label6.Text  = count1.ToString();
            label12.Text = count2.ToString();
            string out1 = String.Format("{0:0.00}", percent1);
            string out2 = String.Format("{0:0.00}", percent2);

            label11.Text = out1 + "%";
            label10.Text = out2 + "%";
            int result = count1 - count2;

            label9.Text = result.ToString();
            F           = null;
            F           = p.loadStudentType(F, type);
            datas       = p.change(F);
            foreach (string s in datas)
            {
                textBox1.Text = string.Join(Environment.NewLine, datas);
            }
            using (StreamWriter sw = new StreamWriter("DanhSachTheoDoituongDuThi.txt"))
            {
                foreach (string s in datas)
                {
                    sw.WriteLine(s);
                }
            }

            btnFileout.Enabled = true;
        }
예제 #19
0
        private void Thủ_Khoa_Load(object sender, EventArgs e)
        {
            LinkListFullInfo temp = new LinkListFullInfo();

            F    = temp.setStGioi(F);
            F    = F.MergeSort(F);
            temp = F;
            double max   = temp.totalScore;
            int    count = 0;

            datas = changedatas(F, max, ref count);

            foreach (string s in datas)
            {
                textBox1.Text = string.Join(Environment.NewLine, datas);
            }
            using (StreamWriter sw = new StreamWriter("Danhsachthukhoa.txt"))
            {
                foreach (string s in datas)
                {
                    sw.WriteLine(s);
                }
            }
        }
예제 #20
0
        private void FrmFullInfo_Load(object sender, EventArgs e)
        {
            LinkListFullInfo temp = new LinkListFullInfo();

            F = temp.loadfullInfo(F);
        }
예제 #21
0
        public LinkListFullInfo loadStudentType(LinkListFullInfo F, int type)
        {
            Console.OutputEncoding = Encoding.Unicode;
            LinkListStudent S = new LinkListStudent();

            S.loadListStudent(S);
            LinkListScore L = new LinkListScore();

            L.loadListScore(L);
            DateTime temp = DateTime.Now;
            int      ID, type1, dut;
            string   sex;
            string   lastName, name, rank = null;
            DateTime birthdate;
            double   mathScore, literatureScore, englishScore, totalScore, minScore;

            while (S != null && L != null)
            {
                if (S.type != type)
                {
                    S = S.Next;
                    L = L.Next;
                    continue;
                }
                else
                {
                    LinkListFullInfo p = new LinkListFullInfo();
                    ID              = S.ID;
                    lastName        = S.lastName;
                    name            = S.name;
                    sex             = S.sex;
                    type1           = S.type;
                    mathScore       = L.mathScore;
                    literatureScore = L.literatureScore;
                    englishScore    = L.englishScore;
                    minScore        = scoreMin(L.mathScore, L.literatureScore, L.englishScore);

                    if (S.type == 1)
                    {
                        dut = 2;
                    }
                    else if (S.type == 2)
                    {
                        dut = 1;
                    }
                    else
                    {
                        dut = 3;
                    }
                    birthdate  = S.birthDate;
                    totalScore = L.mathScore + L.literatureScore + L.englishScore + dut;
                    if (totalScore >= 24 && minScore >= 7)
                    {
                        rank = "Giỏi";
                    }
                    if (totalScore >= 21 && totalScore < 24)
                    {
                        if (minScore >= 6)
                        {
                            rank = "Khá";
                        }
                    }
                    if (totalScore >= 15 && totalScore < 21)
                    {
                        if (minScore >= 4)
                        {
                            rank = "Trung Bình";
                        }
                    }
                    if (totalScore < 15 || totalScore < 15 && minScore < 4 || minScore < 4)
                    {
                        rank = "Trượt";
                    }
                    addFullInfo(p, ID, lastName, name, sex, birthdate, mathScore, literatureScore, englishScore, minScore, totalScore, rank, type);
                    addFull(ref F, p);
                }
                S = S.Next;
                L = L.Next;
            }
            return(F);
        }