bubble sort by 51b

a[99],*p=a,*q;c,s;main(t){for(;~scanf("%d",p);)p++;for(;p-->a;)for(q=a;++q<p;puts(""))for(*q>q[1]?s++,t=*q,*q=q[1],q[1]=t:1,t=!printf("compare =%3d   swap =%3d   data:",++c,s);t++<*a;)printf("%3d",a[t]);}

Note that non-ascii characters in the above source code will be escaped (such as \x9f).

download

return to the top page