#include <iostream.h>
void gen_permutations(int [], int, int);
void swap(int [], int, int);
void main()
{
int list[5];
for (int i = 0; i < 5; i++)
{
list[i] = i+1;
}
permutations(list, 0, 4);
char z;
cin >> z;
}
void permutations(int list[], int left, int n)
{
if (left == n)
{
cout << endl << "(";
for (int i = 0; i < 5; i++)
{
cout << list[i];
if (i < 4) cout << ",";
}
cout << ")";
}
else
{
for (int i = left; i <= n; i++)
{
swap(list, left, i);
gen_permutations(list, left+1, n);
swap(list, left, i);
}
}
}
void swap(int list[], int left, int x)
{
int temp = list[left];
list[left] = list[x];
list[x] = temp;
}