bubble sort by 51b

import std.stdio;int[99]a;int*p=&*a,q;void main(){for(;~scanf("%d",p);)p++;for(int t,c,s;p-->&*a;)for(q=&*a;++q<p;puts="")for(t=*q>q[1]?t=*q,*q=q[1],q[1]=t,!++s:0,writef("compare =%3d   swap =%3d   data:",++c,s);t++<*a;)writef("%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