Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace MigrateToPY
- {
- class Program
- {
- public static long count = 0;
- // public static int countOfIterations = 1;
- public static void printAllCents(int ind, int[] denom, int N, int[] vals)
- {
- if (N == 0)
- {
- if (ind < denom.Length)
- {
- for (int i = ind; i < denom.Length; i++)
- vals[i] = 0;
- }
- //Console.WriteLine("Kombinacja numer: {0}", countOfIterations);
- foreach (var c in vals)
- {
- //Console.WriteLine(c);
- count++;
- }
- //Console.WriteLine();
- //countOfIterations++;
- return;
- }
- if (ind == (denom.Length))
- {
- vals[ind - 1] = 0;
- return;
- }
- int currdenom = denom[ind];
- for (int i = 0; i <= (N / currdenom); i++)
- {
- vals[ind] = i;
- printAllCents(ind + 1, denom, N - i * currdenom, vals);
- }
- }
- static void Main(string[] args)
- {
- int[] denom = { 1, 2, 5, 10, 50 };
- int[] vals = new int[denom.Length];
- int N = 1000;
- //Console.WriteLine("Twoje kombinacje: ");
- printAllCents(0, denom, N, vals);
- Console.WriteLine("Twoja kwota to: {0}", N);
- Console.Write("Twoje liczby to:");
- foreach (var c in denom) Console.Write(c + " ");
- Console.WriteLine();
- Console.WriteLine("Ilosc twoich wynikow to: {0}",count/denom.Length);
- Console.ReadKey();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement