I am applying bubble sort on an int array and it is working but on console (output) i want complete swapping for example int array:[3 2 5 4 1] and required output should be :23541 23451 23415 23145 and in last the sorted int array 12345.Here is the code.
int[] b = { 3, 2, 5, 4, 1 };
int c;
for (int p = 0; p <= b.Length - 2; p++)
{
for (int i = 0; i <= b.Length - 2; i++)
{
if (b[i] > b[i + 1])
{
c = b[i + 1];
b[i + 1] = b[i];
b[i] = c;
}
}
}
foreach (int aa in b)
Console.Write(aa + " ");
Console.ReadLine();