Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using System.Diagnostics;
- using System.Runtime.CompilerServices;
- namespace Combinations
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- private void button1_Click(object sender, EventArgs e)
- {
- int lenghtNumber = 11;
- int[] valueToReturn = new int[lenghtNumber];
- generateAllBinary(lenghtNumber, valueToReturn, 0);
- }
- static void generateAllBinary(int lenghtNumber, int [] recursiveArray, int i)
- {
- if (i == lenghtNumber)
- {
- printResult(recursiveArray, lenghtNumber);
- return;
- }
- recursiveArray[i] = 1;
- generateAllBinary(lenghtNumber, recursiveArray, i + 1);
- recursiveArray[i] = 2;
- generateAllBinary(lenghtNumber, recursiveArray, i + 1);
- }
- static void printResult(int[] returningArray, int lenghtNumber)
- {
- string stringToAdd = "";
- for (int i = 0; i < lenghtNumber; i++)
- {
- stringToAdd += returningArray[i];
- }
- Debug.WriteLine(stringToAdd);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement