Exemplo n.º 1
0
        public void CheckTable()
        {
            _table = _prototable.CreateMargin();
            int dim1 = _table.LengthOf(0);

            Assert.AreEqual(dim1, 101);
            int dim2 = _table.LengthOf(1);

            Assert.AreEqual(dim2, 4);
            _table[1, 0] = 1;
            Assert.AreEqual(_table[1, 0], 1);
        }
Exemplo n.º 2
0
        public IDPTable DPTableGenerator(IDPTable table)
        {
            int i, j, k;

            for (k = 2; k < table.LengthOf(1); k++)
            {
                for (i = 2; i < table.LengthOf(0); i++)
                {
                    table[i, k] = i;
                    for (j = 1; j < i; j++)
                    {
                        int min = table[j - 1, k - 1] > table[i - j, k] ? table[j - 1, k - 1] + 1 : table[i - j, k] + 1;
                        table[i, k] = min < table[i, k] ? min : table[i, k];
                    }
                }
            }
            return(table);
        }
Exemplo n.º 3
0
 public void CheckAlgo()
 {
     CheckTable();
     _table = _dp.DPTableGenerator(_table);
     Assert.AreEqual(_table[_building.FloorNum(), _iphone.Num()], 9);
 }