# Steps of Bubble Sort

QUESTION

You have been given an array A of size N you need to sort this array non-decreasing order using bubble sort. However, you do not need to print the sorted array . You just need to print the steps required to sort this array using bubble sort\n\nInput Format\n\nThe first line consists of a single integer N\nN denoting size of the array. The next line contains N space separated integers denoting the elements of the array.\n\nOutput Format Print each step on new line as shown below\n\nConstraints \n1<=N<=100\n1<=a[i]<=100.

“TESTCASE_1”: “6\n5 8 1 3 4 0\n###—###SEPERATOR—###—\n5 1 3 4 0 8 \n1 3 4 0 5 8 \n1 3 0 4 5 8 \n1 0 3 4 5 8 \n0 1 3 4 5 8”, “TESTCASE_2”: “10\n27 81 85 85 71 76 69 87 42 39\n###—###SEPERATOR—###—\n27 81 85 71 76 69 85 42 39 87 \n27 81 71 76 69 85 42 39 85 87 \n27 71 76 69 81 42 39 85 85 87 \n27 71 69 76 42 39 81 85 85 87 \n27 69 71 42 39 76 81 85 85 87 \n27 69 42 39 71 76 81 85 85 87 \n27 42 39 69 71 76 81 85 85 87 \n27 39 42 69 71 76 81 85 85 87 \n27 39 42 69 71 76 81 85 85 87”, “TESTCASE_3”: “20\n27 81 85 85 71 76 69 87 42 39 100 95 65 25 88 62 6 15 44 40\n###—###SEPERATOR—###—\n27 81 85 71 76 69 85 42 39 87 95 65 25 88 62 6 15 44 40 100 \n27 81 71 76 69 85 42 39 85 87 65 25 88 62 6 15 44 40 95 100 \n27 71 76 69 81 42 39 85 85 65 25 87 62 6 15 44 40 88 95 100 \n27 71 69 76 42 39 81 85 65 25 85 62 6 15 44 40 87 88 95 100 \n27 69 71 42 39 76 81 65 25 85 62 6 15 44 40 85 87 88 95 100 \n27 69 42 39 71 76 65 25 81 62 6 15 44 40 85 85 87 88 95 100 \n27 42 39 69 71 65 25 76 62 6 15 44 40 81 85 85 87 88 95 100 \n27 39 42 69 65 25 71 62 6 15 44 40 76 81 85 85 87 88 95 100 \n27 39 42 65 25 69 62 6 15 44 40 71 76 81 85 85 87 88 95 100 \n27 39 42 25 65 62 6 15 44 40 69 71 76 81 85 85 87 88 95 100 \n27 39 25 42 62 6 15 44 40 65 69 71 76 81 85 85 87 88 95 100 \n27 25 39 42 6 15 44 40 62 65 69 71 76 81 85 85 87 88 95 100 \n25 27 39 6 15 42 40 44 62 65 69 71 76 81 85 85 87 88 95 100 \n25 27 6 15 39 40 42 44 62 65 69 71 76 81 85 85 87 88 95 100 \n25 6 15 27 39 40 42 44 62 65 69 71 76 81 85 85 87 88 95 100 \n6 15 25 27 39 40 42 44 62 65 69 71 76 81 85 85 87 88 95 100 \n6 15 25 27 39 40 42 44 62 65 69 71 76 81 85 85 87 88 95 100 \n6 15 25 27 39 40 42 44 62 65 69 71 76 81 85 85 87 88 95 100 \n6 15 25 27 39 40 42 44 62 65 69 71 76 81 85 85 87 88 95 100”, “TESTCASE_4”: “0\n###—###SEPERATOR—###—\n0”, “TESTCASE_5”: “0\n###—###SEPERATOR—###—\n0

``````#include <stdio.h>

int main()
{
int n;
scanf("%d",&n);
int a[n];
int i,j,k,temp;
//int exchange =0;
for (i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
printf("\n");
for (i=0;i<n-1;++i)
{
for(j=0;j<n-i-1;++j)
{
if(a[j]>a[j+1])
{

temp=a[j];
a[j]=a[j+1];
a[j+1]=temp;
}
}
for(k=0;k<n;k++)
printf("%d ",a[k]);
printf("\n");
}
// printf ("%d",exchange);

return 0;
}``````