Here only 26 English letters are arranged in all orders.
Code is as follows
//Recursion on ABCD....
#include<iostream>
using namespace std;
const int N = 10000;
char box[N];
int vis[N];
int aim;
void recursion(int n)
{
if(n>aim)
{
for(int i=1;i<=aim;i++)
{
cout<<box[i]<<" ";
}
cout<<'\n';
return ;
}
for(int i=1;i<=aim;i++)
{
if(vis[i]==0){
box[n]=box[n]+i;
vis[i]=1;
recursion(n+1);
vis[i]=0;
box[n]=box[n]-i;
}
}
}
int main()
{
cin>>aim;//Entering different numbers represents how many first letters (starting from A) to sort the output
memset (box,(char)64,sizeof box);
recursion(1);
return 0;
}