0

hie guys have a textbook that am reading there is a code that i need some help understanding better....can anyone explain to me line by line whats really going on....

No need to explain the main function though.......its a program that calculates permutation of whole numbers...Cheers!

```
#include<iostream>
#include<conio.h>
#include<string.h>
using namespace std;
int count=0;
void dis(char a[],int n)
{
for(int jk=n-1;jk>=0;jk--)
{
cout<<a[jk];
}
cout<<" ";
}
void shift(char a[],int n)
{
char s;
s=a[n-1];
for(int i=n-1;i>0;i--)
a[i]=a[i-1];
a[0]=s;
}
void per(char a[],int m,int n)
{
for(int i=0;i<m;i++)
{
if(m>1)
{
shift(a,m);
per(a,m-1,n);
}
else
{
dis(a,n);
count++;
}
}
}
void main()
{
int n;
cout<<"Enter a whole number : ";
cin>>n;
char *a = new (char[n]);
for(int i=0;i<n;i++)
a[i] = n-i+48;
cout<<"Possible permutations are : ";
per(a,n,n);
cout<<"Total No Of Permutations Is "<<count;
_getch();
}
```