示例#1
0
        public void print()
        {
            daraalal dood1 = dood;

            while (dood1 != null)
            {
                System.Console.WriteLine(dood1.a.root1().hus().Item1 + "\t" + dood1.a.root1().hus().Item2);
                //               cout << dood.a << "\n";
                dood1 = dood1.prev;
            }
        }
示例#2
0
        public void oruul(BinaryTree aq)
        {
            daraalal oroh = deed, anew = new daraalal();

            anew.a = aq;
            if (deed == null && dood == null)
            {
                dood = anew;
                deed = anew;
            }
            else
            {
                if (anew.a.root1().hus().Item2 < deed.a.root1().hus().Item2)
                {
                    oroh = null;
                }
                else
                {
                    while (oroh.a.root1().hus().Item2 < anew.a.root1().hus().Item2)
                    {
                        if (oroh == dood)
                        {
                            break;
                        }
                        if (oroh.next.a.root1().hus().Item2 > anew.a.root1().hus().Item2)
                        {
                            break;
                        }
                        oroh = oroh.next;
                    }
                }
                //oroh=oroh.prev;
                if (oroh == null)
                {
                    anew.next = deed; deed.prev = anew; deed = anew;
                }
                else if (oroh == dood)
                {
                    anew.prev = dood; dood.next = anew; dood = anew;
                }
                else
                {
                    anew.next      = oroh.next;
                    oroh.next.prev = anew;
                    oroh.next      = anew;
                    anew.prev      = oroh;
                }
            }
            hemj++;
        }
示例#3
0
        public BinaryTree garga()
        {
            // Console.WriteLine("sdf");
            if (deed == null)
            {
                return(null);
            }
            // Console.WriteLine("sdf");
            BinaryTree temp = deed.a;

            if (dood == deed)
            {
                dood = deed = null;
            }
            else
            {
                deed      = deed.next;
                deed.prev = null;
            }
            // System.Console.WriteLine("sdf  "+temp.root1().hus().Item1 + "\t" + temp.root1().hus().Item2);
            //            cout << temp << endl;
            hemj--;
            return(temp);
        }
示例#4
0
        public void shah()
        {
            if (readFile() == true)
            {
                //Console.WriteLine(str);
                foreach (char currentChar in strs)
                {
                    if (Dawtamj.ContainsKey(currentChar.ToString()))
                    { Dawtamj[currentChar.ToString()]++; }
                    else
                    { Dawtamj.Add(currentChar.ToString(), 1); }
                }
                daraalal dar = new daraalal();

                foreach (KeyValuePair<String, int> kvp in Dawtamj)
                {
                    BinaryTree b = new BinaryTree();
                    b.insert(Tuple.Create(kvp.Key, kvp.Value));
                    dar.oruul(b);

                }
                dar.Uusge();

                foreach (KeyValuePair<String, int> kvp in Dawtamj)
                {
                    if (kvp.Key.CompareTo(" ") == 0)
                        Code_hus.Add("*", Display1(dar.asdqwe().root1(), kvp.Key, ""));
                    else
                        Code_hus.Add(kvp.Key, Display1(dar.asdqwe().root1(), kvp.Key, ""));
                }

                String ner = str.Substring(0, str.Length - 4) + ".pjl";

                using (StreamWriter writer = new StreamWriter(ner))
                {
                    writer.Write(Nuutsal(Code_hus.Count.ToString()) +"\n");
                    foreach (KeyValuePair<String, String> kvp in Code_hus)
                    {
                        writer.Write(Nuutsal(kvp.Key + " " + kvp.Value) + "\n");

                        //Console.WriteLine("Code {0}:\t{1}", kvp.Key, kvp.Value);
                      //  richTextBox1.Text = richTextBox1.Text + kvp.Key + " " + kvp.Value + "\n";
                    }

                    for (int i = 0; i < strs.Length; i++)
                    {
                        if (strs.Substring(i, 1).CompareTo(" ") == 0)
                        {
                            String code = Code_hus["*"];
                            shine = shine + code;//.PadLeft(6,'0');
                        }
                        else {
                            String code = Code_hus[strs.Substring(i, 1)];
                            shine = shine + code;
                        }
                    }
                    for(int i = 0; i < shine.Length; i = i + 8)
                    {
                        String a;
                        if (shine.Length - i < 8) a = shine.Substring(i, shine.Length - i);
                        else a = shine.Substring(i, 8);
                        String baa = bintodec(a).ToString();
                        //baa = baa.PadLeft(3, '0');
                        int baa1 = Int32.Parse(baa);
                        char baa3 = (char)baa1;
                        String baa2 = baa3.ToString();
                        writer.Write(Nuutsal(baa2));
                    }
                }
            }
            else
            {
                MessageBox.Show( "Та .txt өргөтгөлтэй файл сонгоно уу?","Алдаа" ,MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
示例#5
0
 public daraalal()
 {
     deed = null; dood = null; next = null; prev = null; hemj = 0;
 }
示例#6
0
        public BinaryTree asdqwe()
        {
            daraalal dood1 = dood;

            return(dood1.a);
        }