コード例 #1
0
        private void GetDrum(Retea retea, Nod nodStoc, Nod nodSursa)
        {
            nodStoc.Distanta = 0;
            Stack <Nod> stack = new Stack <Nod>();

            List <Drum> drumuri = new List <Drum>();

            List <Nod> noduriDrum = new List <Nod>();

            stack.Push(nodStoc);

            while (stack.Count() != 0)
            {
                Nod nodCurent = stack.Pop();
                noduriDrum.Add(nodCurent);

                if (nodCurent.Id == nodSursa.Id)
                {
                    noduriDrum.Reverse();
                    drumuri.Add(new Drum(retea, noduriDrum));
                    noduriDrum = new List <Nod>();
                }

                List <Arc> arce = retea.Arce.Where(arc => arc.Y.Id == nodCurent.Id && arc.X.Id == nodCurent.Predecesor.Id).ToList();

                arce.ForEach(a => {
                    stack.Push(a.X);
                });
            }
        }
コード例 #2
0
 public IEnumerator GetEnumerator()
 {
     for (Nod p = prim; p != null; p = p.urm)
     {
         yield return(p.info);
     }
 }
コード例 #3
0
        public Monster(Nod start, Spawn pSpawn, byte type) : base(start, pSpawn, type)
        {
            Nod nod = GameServer.world.GetPositionAtTile(start.X, start.Y);

            posX = (int)nod.X;
            posY = (int)nod.Y;
        }
コード例 #4
0
ファイル: Form1.cs プロジェクト: dozsolti/Facultate
 public void draw(Nod nod)
 {
     grp.FillEllipse(Brushes.Black, nod.x, nod.y, size, size);
     grp.DrawEllipse(Pens.Black, nod.x, nod.y, size, size);
     grp.DrawLine(Pens.Black, nod.parentCoord.X + size / 2, nod.parentCoord.Y + size / 2, nod.x + size, nod.y + size / 2);
     pictureBox1.Image = bmp;
 }
コード例 #5
0
        private List <SampleDataModel> NodToData(Nod nd, string parent)
        {
            var sampleTree = new List <SampleDataModel>();
            int pos        = i;

            if (nd.ch.Count == 3)
            {
                sampleTree.Add(new SampleDataModel {
                    Id = pos.ToString(), ParentId = parent, Name = nd.ch[1].ToString()
                });
            }
            else
            {
                sampleTree.Add(new SampleDataModel {
                    Id = pos.ToString(), ParentId = parent, Name = nd.ch[0].ToString()
                });
            }
            i++;
            if (nd.nods.Count > 0)
            {
                sampleTree.AddRange(NodToData(nd.nods[0], pos.ToString()));
            }
            if (nd.nods.Count > 1)
            {
                sampleTree.AddRange(NodToData(nd.nods[1], pos.ToString()));
            }
            return(sampleTree);
        }
コード例 #6
0
        Nod createnod(char cha)
        {
            Nod tmp = new Nod();

            tmp.ch.Add(cha);
            return(tmp);
        }
コード例 #7
0
ファイル: ListaGen.cs プロジェクト: alex-fulop/POO
        private static void DeleteNode(Nod current)
        {
            var delNod = current.Next;

            current.Next = current.Next.Next;
            delNod.Next  = null;
        }
コード例 #8
0
ファイル: ListeSimpluInlantuite.cs プロジェクト: Andradaz/Up
    public void AdaugaLaFinal(object data)
    {
        Nod newNod = new Nod();

        newNod.val  = data;
        curent.Next = newNod;
        curent      = newNod;
        nr++;
    }
コード例 #9
0
        private void Formula_TextChanged(object sender, TextChangedEventArgs e)
        {
            text = formula.Text;
            reset();

            text = tostrict(text);
            Console.WriteLine(text);
            MyNod = tonod();
        }
コード例 #10
0
ファイル: Form1.cs プロジェクト: dozsolti/Facultate
        private void Start()
        {
            bmp = new Bitmap(pictureBox1.Width, pictureBox1.Height);
            grp = Graphics.FromImage(bmp);

            radacina = new Nod(bmp.Width / 2, 0, 16, 5, new Point(bmp.Width / 2, 0));
            draw(radacina);

            frunze.Add(radacina);
        }
コード例 #11
0
ファイル: ListaGen.cs プロジェクト: alex-fulop/POO
        private Nod GetCurrent(T t, Nod current)
        {
            while (current != null && current.Data.Equals(t))
            {
                start   = start.Next;
                current = start;
            }

            return(current);
        }
コード例 #12
0
        public void UsualDateBinTest()
        {
            int firstN   = 585;
            int secondN  = 81;
            int expected = 9;

            int nod = Nod.BinaryNod(firstN, secondN);

            Assert.AreEqual(expected, nod, "NOD not found correctly");
        }
コード例 #13
0
        private void InaintareReetichetare(Retea retea, Nod x)
        {
            List <Arc> arceDinX = retea.Arce.Where(a => a.X.Id == x.Id).OrderBy(a => a.Y.Id).ToList();

            Queue <Arc> coadaArce = new Queue <Arc>(arceDinX);
            Arc         arc       = coadaArce.Dequeue();

            bool esteReetichetat = false;

            do
            {
                if (arc.EsteAdmisibil(retea))
                {
                    arc.Flux += Math.Min(x.GetExces(retea), arc.GetCapacitateReziduala(retea));

                    Arc arcInvers = retea.Arce.FirstOrDefault(a => a.X.Id == arc.Y.Id && a.Y.Id == arc.X.Id);

                    if (arcInvers == null)
                    {
                        arcInvers = new Arc(arc.Y, arc.X, 0, 0);
                        retea.Arce.Add(arcInvers);
                    }

                    if (!_L.Contains(arc.Y) && !arc.Y.EsteNodSursa && !arc.Y.EsteNodStoc)
                    {
                        _L.Enqueue(arc.Y);
                    }
                }

                if (x.GetExces(retea) > 0)
                {
                    if (coadaArce.Count() > 0)
                    {
                        arc = coadaArce.Dequeue();
                    }
                    else
                    {
                        x.Distanta = arceDinX.Where(a => a.GetCapacitateReziduala(retea) > 0).Min(a => a.Y.Distanta + 1);

                        esteReetichetat = true;
                    }
                }

                Console.WriteLine(retea.ToString());

                Console.Write("Distante:");
                retea.Noduri.Select(n => n.Distanta).ToList().ForEach(d => Console.Write($"{d}, "));
                Console.WriteLine("\n");
            } while (x.GetExces(retea) != 0 && !esteReetichetat);

            if (x.GetExces(retea) > 0)
            {
                _L.Enqueue(x);
            }
        }
コード例 #14
0
ファイル: ListeSimpluInlantuite.cs プロジェクト: Andradaz/Up
    public void AdaugaLaInceput(object data)
    {
        Nod newNod = new Nod()
        {
            val = data
        };

        newNod.Next = cap.Next; //new node will have reference of head's next reference
        cap.Next    = newNod;   //and now head will refer to new node
        nr++;
    }
コード例 #15
0
 public void Push(Nod n)
 {
     dim++;
     Nod[] aux = new Nod[dim];
     aux[0] = n;
     for (int i = 1; i < dim; i++)
     {
         aux[i] = values[i - 1];
     }
     values = aux;
 }
コード例 #16
0
        public void CreareText()
        {
            Nod aux = cap;

            while (aux != null)
            {
                ListaScoruri = ListaScoruri + aux.nume + "     " + aux.time + "     " + aux.val + "\n";
                aux          = aux.urm;
            }
            //ListaScoruri = ListaScoruri + "\n" + System.DateTime.Now.Hour.ToString() + " : " + System.DateTime.Now.Minute.ToString() + "         " + curent.nume + "         " + curent.val;
        }
コード例 #17
0
ファイル: ListaGen.cs プロジェクト: alex-fulop/POO
 private void PerformDeletion(Nod current)
 {
     if (end == current.Next)
     {
         DeleteLast(current);
     }
     else
     {
         DeleteNode(current);
     }
 }
コード例 #18
0
ファイル: ListaGen.cs プロジェクト: alex-fulop/POO
        public void insertToFront(T type)
        {
            var nod = new Nod(type);

            nod.Next = start;
            start    = nod;
            if (end == null)
            {
                end = nod;
            }
        }
コード例 #19
0
        public Retea UpdateRetea(Retea retea)
        {
            Initializare(retea);

            while (_L.Count() != 0)
            {
                Nod nod = _L.Dequeue();
                InaintareReetichetare(retea, nod);
            }

            return(retea);
        }
コード例 #20
0
 public void Sterge(ElemType e)
 {
     for (Nod p = prim; p != null; p = p.urm)
     {
         if (p.urm.info.Equals(e))
         {
             p.urm = p.urm.urm;
             dimensiune--;
             break;
         }
     }
 }
コード例 #21
0
        public void AdaugaInceput(string nume, string time, object data)
        {
            Nod newNod = new Nod();

            newNod.val  = data;
            newNod.nume = nume;
            newNod.urm  = cap;
            newNod.time = time;
            cap         = newNod;
            curent      = newNod;
            nr++;
        }
コード例 #22
0
        public void NullArgBinTest()
        {
            int firstN   = 0;
            int secondN  = 81;
            int thirdN   = 9;
            int fourth   = 3;
            int more     = 0;
            int expected = 0;

            int nod = Nod.BinaryNod(firstN, secondN, thirdN, fourth, more);

            Assert.AreEqual(expected, nod, "NOD not found correctly");
        }
コード例 #23
0
        public void NegativArgEvklidTest()
        {
            int firstN   = -585;
            int secondN  = 81;
            int thirdN   = -9;
            int fourth   = 3;
            int more     = 12;
            int expected = 3;

            int nod = Nod.NodEvklid(firstN, secondN, thirdN, fourth, more);

            Assert.AreEqual(expected, nod, "NOD not found correctly");
        }
コード例 #24
0
ファイル: ListaGen.cs プロジェクト: alex-fulop/POO
        private Nod DeleteNodes(T t, Nod current)
        {
            if (current.Next.Data.Equals(t))
            {
                PerformDeletion(current);
            }
            else
            {
                current = current.Next;
            }

            return(current);
        }
コード例 #25
0
        public void nod_10and20_10returned()
        {
            // arrange
            int x        = 10;
            int y        = 20;
            int expected = 10;

            // act
            int actual = Nod.nod(x, y);

            // assert
            Assert.AreEqual(expected, actual);
        }
コード例 #26
0
        public Nod Pop()
        {
            dim--;
            Nod[] aux = new Nod[dim];
            for (int i = 0; i < dim; i++)
            {
                aux[i] = values[i];
            }
            Nod a = values[dim];

            values = aux;
            return(a);
        }
コード例 #27
0
        public MainForm(Nod nods)
        {
            InitializeComponent();

            //_data = GetSampleData();
            _data = NodToData(nods, string.Empty);
            _tree = GetSampleTree(_data);
            TreeHelpers <SampleDataModel> .CalculateNodePositions(_tree);

            CalculateControlSize();

            DoubleBuffered   = true;
            treePanel.Paint += treePanel_Paint;
        }
コード例 #28
0
ファイル: ListeSimpluInlantuite.cs プロジェクト: Andradaz/Up
    public void Afisare()
    {
        //Traverse from head
        Console.Write("Cap ->");
        Nod aux = head;

        while (aux.Next != null)
        {
            aux = aux.Next;
            Console.Write(aux.val);
            Console.Write("->");
        }
        Console.Write("NULL");
    }
コード例 #29
0
        public void nodBigInputTest_10and20and30_10returned()
        {
            // arrange
            int x        = 10;
            int y        = 20;
            int z        = 30;
            int expected = 10;

            // act
            int actual = Nod.nodBigInput(x, y, z);

            // assert
            Assert.AreEqual(expected, actual);
        }
コード例 #30
0
ファイル: ListaGen.cs プロジェクト: alex-fulop/POO
        public void insertToEnd(T type)
        {
            var node = new Nod(type);

            if (start == null)
            {
                start = node;
            }
            if (end != null)
            {
                end.Next = node;
            }
            end = node;
        }
コード例 #31
0
ファイル: Form1.cs プロジェクト: ItramariN/lab
        private void buttonCrypto_Click(object sender, EventArgs e)
        {
            string cipher,substring,tempstring="";
            int indexfirst,indexlast,i,j,k,a,b;
            List<int> distList = new List<int>();
            List<Nod> NodList = new List<Nod>();
            Nod currentnod=new Nod();
            bool check;

            if (textBox_Cipher.Lines.Count() == 0)
            {
                MessageBox.Show("Не введен шифротекст!");
                return;
            }
            
            textBox_Source.Clear();
            cipher = textBox_Cipher.Text.ToString();
            for (indexfirst = 0; indexfirst < cipher.Length; indexfirst++)
            {
                if (Array.IndexOf(Alphabet, cipher[indexfirst]) == -1)
                {
                    cipher = cipher.Remove(indexfirst, 1);
                    indexfirst--;
                }
            }
            for (int length = 10; length >= 3; length--)
            {
                for (indexfirst = 0; indexfirst < cipher.Length-length; indexfirst++)
                {
                    substring = cipher.Substring(indexfirst,length);
                    if ((textBox_Source.Text.IndexOf(substring) == -1) && (textBox_Source.Text.IndexOf(substring.Substring(0,3)) == -1))
                    {
                        tempstring = "";
                        indexlast = indexfirst + length - 1;
                        while (indexlast > -1)
                        {
                            indexlast = cipher.IndexOf(substring, indexlast + 1);
                            if (indexlast > -1)
                            {
                                tempstring = tempstring + "pos=" + indexlast + " dist=" + (indexlast - indexfirst) + "; ";
                                distList.Add(indexlast - indexfirst);
                            }
                        }
                        if (tempstring != "")
                            textBox_Source.AppendText("\"" + substring + "\" " + "starting pos=" + indexfirst + " " + tempstring + "\r\n");
                    }
                }
            }
            distList.Sort();
            for (i = 1; i < distList.Count; i++)
            {
                if (distList[i] == distList[i - 1])
                {
                    distList.RemoveAt(i);
                    i--;
                }
            }
            for (i = 0; i < distList.Count; i++)
            {
                for (j = i+1; j < distList.Count; j++)
                {
                    check = true;
                    a = distList[i];
                    b = distList[j];
                    while ((a!=0) && (b!=0))
                    {
                        if (a > b)
                            a = a % b;
                        else
                            b = b % a;
                    }
                    currentnod.value=a+b;
                    currentnod.chance=1;
                    if (currentnod.value == 1)
                        continue;
                    for (k = 0; k < NodList.Count; k++)
                    {
                        if (NodList[k].value == currentnod.value)
                        {
                            check = false;
                            currentnod = NodList[k];
                            currentnod.chance++;
                            NodList[k] = currentnod;
                            break;
                        }
                    }
                    if (check)
                        NodList.Add(currentnod);
                }
            }
            indexfirst = 0;
            currentnod = NodList[0];
            for (i = 0; i < NodList.Count; i++)
            {
                indexfirst+=NodList[i].chance;
                if (NodList[i].chance>currentnod.chance)
                    currentnod = NodList[i];
            }
            textBox_Source.AppendText("Криптоанализ завершен!\r\n");
            textBox_Source.AppendText("Вероятная длинна ключа: "+currentnod.value+". Вероятность: "+(currentnod.chance*100/indexfirst)+"%\r\n");
            
        }