C#: 0 & 1 Permutations

后端 未结 2 1571
粉色の甜心
粉色の甜心 2021-01-27 00:03

I want to list permutations with only 0 and 1. Similar to binary but allowing variable lengths, doesn\'t have to equal 8 length. For example:

0
1
00
01
10
11
000         


        
2条回答
  •  天涯浪人
    2021-01-27 00:05

    You can also use:

    using System;
    
    class Test
    {
        static void permute(int len)
        {
            for (int i=1; i<=len; i++) 
            {
                for (int j=0; j

    Which involves no recursion :)

提交回复
热议问题