#include <iostream>
#define MAX 100
int num[MAX];
int n;
int nrows = 0;
using namespace std;
void print()
{
if (num != 0) {
for (int j = 0; j <n; j++)
cout << num[j];
cout <<"\n";
}
}
void leftRotate ( int n)
{int tmp;
for(int k =1; k<n-1; ++k)
{
tmp = num[k];
num[k]= num[k+1];
num[k+1] = tmp;}
}
void Permute (int k)
{
int i,temp;
if (k == 2)
{nrows++;
print();
return ;
}
temp = k-1 ;
for (i = 0; i <temp; ++i)
{
leftRotate (temp);
Permute (temp);
}
}
int main ()
{
cout << "number must be between 3 and 10 \n";
cin >> n;
cout << endl;
for (int j = 0; j < n; ++j)
{
num[j] = j+1;
}
Permute (n);
cout << "nrows=" <<nrows << "\n";
}
i just wondering how to change to output from 1D to 2D array. This is because i need to use 2D output to another cases. anyone who could help me?