0

I am having problems with understanding this code. The program should write all permutations of first N numbers.

```
#include <stdio.h>
#include <iostream>
using namespace std;
void print(const int *v, const int size)
{
if (v != 0) {
for (int i = 0; i < size; i++) {
printf("%4d", v[i] );
}
printf("\n");
}
}
void visit(int *Value, int N, int k)
{
static int level = -1;
level = level+1; Value[k] = level;
if (level == N)
print(Value, N);
else
for (int i = 0; i < N; i++)
if (Value[i] == 0)
visit(Value, N, i);
level = level-1; Value[k] = 0;
}
main()
{
const int N = 3;
int Value[N];
for (int i = 0; i < N; i++) {
Value[i] = 0;
}
visit(Value, N, 0);
system("PAUSE");
}
```

This part of code is hard to understand

```
static int level = -1;
level = level+1; Value[k] = level;
```

I mean, i understand it but the question is WHY? ...I am having problems with permutations for a while now.