0

hello, dear all, i have a slightly problem with my assigment algorithm as follows:

```
void write( int *x, int n)
{
if (x != 0) {
for (int i = 0; i < n; i++) {
printf("%4d", x[i] );
}
printf("\n");
}
} // print
void swap(int *x, int i, int j)
{
int t;
t = x[i];
x[i] = x[j];
x[j] = t;
}
void reverse(int *x, int start, int n)
{
int tmp = x[start];
for (int i = start; i <n-1; ++i) {
x[i] = x[n-i-1];
x[n-i-1] = tmp;
}
}
void starterequiv(int *x, int start, int n)
{
write(x, n);
if (start < n) {
int i, j;
for (i = n-1; i > start; i--) {
for (j = i + 1; j < n; j++) {
swap(x, i, j);
starterequiv(x, i, n);
}
reverse(x, i, n);
}
}
}
void initiate(int *x, int n)
{
for (int i = 0; i <n; i++) {
x[i] = i+1;
}
} // init
void main()
{
char buf[100];
int n;
printf("Enter the number of elements: ");
fgets(buf, sizeof(buf), stdin );
sscanf_s(buf, "%d", &n);
if (n > 0 && n <= 100) {
int *x = new int[n];
initiate(x, n);
starterequiv(x, 0, n);
}
}
```

i need an output as follows:

1234

1432

1423

1324

1342

1243

. but i didnt get it. how to fix it?

many thanks.