#include <iostream>
using namespace std;
//Function prototype
void swap(int &,int &);
void cal(int *, int, int length);
int main()
{
int a[] = {1,2,3,4,5,6};
cal(a,0,5);
return 0;
}
void swap(int &a,int &b)
{
int temp;
temp = a;
a = b;
b = temp;
}
void cal(int *a,int first,int length)
{
if (first == length)
{
for (int i=0;i<length;i++)
{
cout << a[i] << "";
}
cout << endl;
}
else
{
for (int i =first;i<length;i++)
{
swap(a[first], a[i]);
cal(a,first+1,length);
swap(a[first],a[i]);
}
}
using namespace std;
//Function prototype
void swap(int &,int &);
void cal(int *, int, int length);
int main()
{
int a[] = {1,2,3,4,5,6};
cal(a,0,5);
return 0;
}
void swap(int &a,int &b)
{
int temp;
temp = a;
a = b;
b = temp;
}
void cal(int *a,int first,int length)
{
if (first == length)
{
for (int i=0;i<length;i++)
{
cout << a[i] << "";
}
cout << endl;
}
else
{
for (int i =first;i<length;i++)
{
swap(a[first], a[i]);
cal(a,first+1,length);
swap(a[first],a[i]);
}
}
}