29 lines
696 B
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System.Collections.Generic;
using System;
public class Program
{
public static void Main(string[] args)
{
List<EntityItem> items = new List<EntityItem>()
{
new EntityItem(2, 10),
new EntityItem(3, 5),
new EntityItem(5, 15),
new EntityItem(7, 7),
new EntityItem(1, 6)
};
int capacity = 10;
List<EntityItem> result = FillKnapsack(items, capacity);
Console.WriteLine("Предмет в рюкзаке:");
foreach (EntityItem item in result)
{
Console.WriteLine($"Вес: {item.Weight}, Стоимость: {item.Value}");
}
}
}
}