Knapsack problem/0-1: Difference between revisions
→{{header|C#}}
Line 1,109:
Random values origin are automatically assigned create integral of quantity and quality
<lang
using System.Text; // rextester.com/
namespace Knapsack
{
Line 1,138:
mass[i]=1+rand.Next(3);
cost[i]=10+rand.Next(9);
Console.
}
Console.WriteLine();
Line 1,160 ⟶ 1,155:
}
bin[list]=bin[list].Substring(1,bin[list].Length-1);
for (k=0; k<n; k++) // inside 01
{
Line 1,169 ⟶ 1,163:
if (amount[list]<= Inside) // current mass < Knapsack
{
Console.
}
}
Line 1,182 ⟶ 1,170:
max=0;
max_num=1;
for (i=0; i < all; i++)
{
if (amount[i]<=Inside && quality[i]>max)
Line 1,189 ⟶ 1,177:
}
}
▲ Console.WriteLine (bin[max_num]);
}
}
|