bubble sort by Purika

u,s,a[99],*p,*v,*q,r;main(k){r=q=a+atoi(gets());for(p=a;p<q;)*p++=atoi(gets());for(;q>a;--q)for(p=a;p<q-1;++p){if(*p>p[1]){++s;*p^=p[1]^=*p^=p[1];}printf("compare = %2d   swap = %2d   data:",++u,s);for(v=a;v<r;)printf(" %2d",*v++);puts("");}}

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

download

return to the top page