static void Main(string[] args)
{
int[] arr = new int[] { 1,2,3,4};
int length = arr.Length;
int[] outArr=new int[length];
SortAll(arr,outArr,length);
Console.WriteLine(count);
}
static int count = 0;
static void SortAll(int[] arr,int[] outArr,int length)
{
if (arr.Length <=0)
{
for (int i = 0; i < outArr.Length; i++)
{
Console.Write(outArr[i]);
}
Console.WriteLine();
count++;
return;
}
for (int i = 0; i < arr.Length; i++)
{
outArr[length-arr.Length] = arr[i];
int[] temp1=new int[arr.Length-1];
for (int j = 0; j < i; j++)
{
temp1[j] = arr[j];
}
for (int j = i+1; j < arr.Length; j++)
{
temp1[j-1] = arr[j];
}
SortAll(temp1,outArr,length);
}
}