#include<bits/stdc++.h>
using namespace std;
int used[50], number[50];
void permutation(int pos, int n)
{
if(pos == n+1)
{
for(int i=1; i<=n; i++)
cout << number[i] << " ";
cout << "\n";
return;
}
for(int i=1; i<=n; i++)
{
if(used[i] == 0)
{
used[i] = 1;
number[pos] = i;
permutation(pos+1, n);
used[i] = 0;
}
}
}
int main()
{
int n;
cout << "Enter Any Number :: ";
cin >> n;
cout << "The Permutation are :: \n";
permutation(1, n);
return 0;
}
Comments
Post a Comment