Exemple #1
0
        static void Main(string[] args)
        {
            Reader.CacheAdd("1 3 5 1 0 5");
            Reader.CacheDisable();

            Lahev[] lahve = new Lahev[3];

            for (int i = 0; i < lahve.Count(); i++)
            {
                lahve[i] = new Lahev(Reader.ReadInt());
            }

            for (int i = 0; i < lahve.Count(); i++)
            {
                lahve[i].Prilij(Reader.ReadInt());
            }

            fronta.Add(new Stav(lahve, 0));

            while (fronta.Count() > 0)
            {
                Stav prvniStav = fronta.First();
                fronta.Remove(prvniStav);
                prvniStav.ProzkoumejSe();
            }
            NalezeneObjemy.Vytiskni();
        }
Exemple #2
0
        public void ProzkoumejSe()
        {
            ProzkoumaneStavy.Add(this);
            for (int i = 0; i < lahve.Count(); i++)
            {
                NalezeneObjemy.Add(lahve[i].stav, pocetKroku);
            }

            for (int i = 0; i < lahve.Count(); i++)
            {
                if (lahve[i].stav == 0)
                {
                    continue;
                }

                for (int j = 0; j < lahve.Count(); j++)
                {
                    if (i == j)
                    {
                        continue;
                    }

                    Stav novy           = new Stav(lahve, pocetKroku + 1);
                    bool prelilJsemNeco = novy.prelij(novy.lahve[i], novy.lahve[j]);

                    if (!prelilJsemNeco)
                    {
                        continue;
                    }

                    if (ProzkoumaneStavy.Contains(novy))
                    {
                        continue;
                    }

                    Program.fronta.Add(novy);
                }
            }
        }