#include<stdlib.h>
#include<stdio.h>

#define MAX 9 
int stat[MAX]={13, 5, 7, 3, 11, 9, 20, 10, 6};

void swap(int i, int j) { int t; t=stat[i]; stat[i]=stat[j]; stat[j]=t; }

void stampa() { int i; for(i=0;i<MAX;i++) printf("%d ",stat[i]); printf("\n"); }

Bubble_Sort() {
  char cambiato=1;
  int i,N=MAX-1;
  while(cambiato) {
    cambiato=0;
    for(i=0;i<N;i++)
      if(stat[i]>stat[i+1]) { cambiato=1; swap(i,i+1); }
    N--;
    stampa(); // Resultati intermedie e risultato finale.
  }
}

main() {   
  stampa(); printf("\n"); // Disordinato.
  Bubble_Sort(); 
}



