代码文本:
#include "stdio.h"
int main(int argc,char *argv[]){
int a[8]={8,5,9,1,4,2,7,6},i,j,k;
printf("OLD: ");
for(k=0;k<8;printf("%2d",a[k++]));
putchar('\n');
for(i=0;i<8;i++){
for(j=0;j<7;j++)
if(a[j]>a[j+1])
k=a[j],a[j]=a[j+1],a[j+1]=k;
printf(" %d: ",i+1);
for(k=0;k<8;printf("%2d",a[k++]));
putchar('\n');
}
return 0;
}