mirror of
https://github.com/Lendaia/oe-alga-feladatok.git
synced 2026-04-23 12:26:07 +01:00
wewewe
This commit is contained in:
@@ -33,14 +33,14 @@ namespace OE.ALGA.Optimalizalas
|
||||
{
|
||||
for (int j = 1; j <= problema.Wmax; j++)
|
||||
{
|
||||
if (j <= problema.W[i - 1])
|
||||
if (j >= problema.W[i - 1])
|
||||
{
|
||||
F[i, j] = F[i - 1, j];
|
||||
int[] tomb = new int[] { (F[i - 1, j]), (F[i - 1, j - problema.W[i-1]] + Convert.ToInt32(problema.P[i-1])) };
|
||||
F[i, j] = tomb.Max();
|
||||
}
|
||||
else
|
||||
{
|
||||
int[] tomb = new int[] { (F[i - 1, j]), (F[i - 1, j - problema.W[i - 1]] + Convert.ToInt32(problema.P[i - 1])) };
|
||||
F[i, j] = tomb.Max();
|
||||
F[i, j] = F[i - 1, j];
|
||||
}
|
||||
lepesszam++;
|
||||
}
|
||||
@@ -54,7 +54,7 @@ namespace OE.ALGA.Optimalizalas
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
return tablazat[problema.N - 1, problema.Wmax - 1];
|
||||
return tablazat[problema.N, problema.Wmax];
|
||||
}
|
||||
public bool[] OptimalisMegoldas()
|
||||
{
|
||||
@@ -66,8 +66,8 @@ namespace OE.ALGA.Optimalizalas
|
||||
{
|
||||
if (tablazat[t, h] != tablazat[t - 1, h])
|
||||
{
|
||||
optimails[t] = true;
|
||||
h = h - problema.W[t];
|
||||
optimails[t-1] = true;
|
||||
h = h - problema.W[t-1];
|
||||
}
|
||||
t--;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user