Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace Lab1_wariacje_bez_powtorzen
- {
- class kom_bez_powt
- {
- private static int numberofCombos;
- private static int n;
- private static int k;
- private static int[] storageArr;
- public static void Main()
- {
- n = 5;
- k = 3;
- storageArr = new int[k];
- GenCombinationsNoRep();
- Console.ReadKey();
- }
- private static void GenCombinationsNoRep(int index = 0, int element = 0)
- {
- if (index >= storageArr.Length)
- {
- PrintCombo();
- return;
- }
- for (int i = element; i < n; i++)
- {
- storageArr[index] = i;
- GenCombinationsNoRep(index + 1, i + 1);
- }
- }
- private static void PrintCombo()
- {
- Console.WriteLine(
- "{0,3}: [{1}]",
- ++numberofCombos,
- string.Join(", ", storageArr));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement