Как сделать так чтобы код изменят введенный массив чисел, ставил меньший на первое место?

Как можно изменить мой код, чтобы вывод был по шагам, точнее код исправлял массив по шагам. Например:

  1. шаг1 - 1 32 4 45
  2. шаг2 - 1 4 32 45 5

Мой код сразу выводит уже исправленный массив чисел. Заранее спасибо.

#include<stdio.h> //to include stdio.h library
int main(void)
{
   int a, b, c, change, length, number[99]; //to define them
   printf("Enter the length of your array:\n"); //asks user for the lenth of array
   scanf("%i",&length); //lets user to iput smth
   printf("Enter %i number(you can enter them in one line and in other lines by clicking enter):\n", length); //asks user for integers
   for(a=0;a<length;a++) //use for loop to write integers in one line as array
   {
    scanf("%d",&number[a]); //lets user to input smth
   }
   for (a=0;a < (length - 1); a++) //use for loop to find minimum elements (n-1) times
   {
   change = a;

   for (b= a + 1; b < length; b++) //finding the next number
    {
   if (number[change] > number[b]) //again compares integers
        change = b;
    }
   if (change != b) //uses some operations to correctly put integers 
    {
    c = number[a];
    number[a] = number[change];
    number[change] = c;
    }
   }
    printf("The final list, after sorting integers:\n"); //prints final result

   for (a = 0; a < length; a++) //final operation that sorts numbers correctly
   {
   printf("%d ", number[a]); //prints sorted integers 
   }
  return 0; //to operate the code
}

Ответы (0 шт):