Power set: Difference between revisions
Content added Content deleted
Line 691: | Line 691: | ||
//Non-recursive version |
//Non-recursive version |
||
⚫ | |||
⚫ | |||
{ |
|||
⚫ | |||
static int [] buf = new int [n]; |
|||
<lang csharp> |
|||
⚫ | |||
⚫ | |||
⚫ | |||
{ |
{ |
||
int |
static int count = 0, n = 4; |
||
int |
static int [] buf = new int [n]; |
||
for (;;) |
|||
⚫ | |||
{ |
{ |
||
int ind = 0; |
|||
for (int i = 0; i <= ind; ++i) Console.Write("{0, 2}", buf [i]); |
|||
⚫ | |||
⚫ | |||
for (;;) |
|||
{ |
|||
for (int i = 0; i <= ind; ++i) Console.Write("{0, 2}", buf [i]); |
|||
⚫ | |||
⚫ | |||
count++; |
|||
if (buf [ind] < n_1) { ind++; buf [ind] = buf [ind - 1] + 1; } |
|||
⚫ | |||
else break; |
|||
} |
|||
⚫ | |||
} |
} |
||
⚫ | |||
} |
} |
||
</lang> |
|||
} |
|||
=={{header|Clojure}}== |
=={{header|Clojure}}== |