#include <iostream>
using namespace std;
//
void perm(int pos, char* str)
{
if(str[pos+1] == '\0')
{
//
cout << str << "\n";
return;
}
//
for(int i=pos;str[i]!='\0';i++)
{
//
swap(str[pos], str[i]);
//
perm(pos+1,str);
//
swap(str[pos], str[i]);
}
}
int main(void)
{
//
char str[] = "1234";
//
perm(0,str);
}