public static void Split(FriendsPresents presents, int n, int m) { operationsCount++; FriendsPresents frA = presents.Give(n, m); FriendsPresents frB = frA.CloneFriendA(); Share(frA, n - 1, 0); Share(frB, n - 1, 1); }
public static void Share(FriendsPresents presents, int n, int m) { if (n == 0) { presents.Give(n, m); var.Add(presents); return; } Split(presents, n, m); }
static void Main(string[] args) { Stopwatch timer = new Stopwatch(); int[] presentsPrice = { 10, 20, 40, 11, 5, 6, 119, 54, 25, 65, 77, 88, 215, 456, 200, 69, 41, 56, 12, 4, 898, 444, 11 }; List <int> frA = new List <int>(); List <int> frB = new List <int>(); int k = 0; FriendsPresents all = new FriendsPresents(presentsPrice, frA, frB, k); timer.Start(); Split(all, presentsPrice.Length, -1); timer.Stop(); TimeSpan time = timer.Elapsed; timer.Reset(); List <string> seq = Sequences(); Console.WriteLine("Operacijų kiekis: " + operationsCount); Console.WriteLine("Dinaminis programavimas užtruko: " + time); Console.WriteLine("Atlikta"); }