na gut. Fangen wir bei i=2 an. Die innere Schleife kläuft dann von anzahl runter bis 2. Wenn nun A[j-1]>A[j] ist, dann ist ein großes Element vor einem kleinen Element. Das ist unschön, und daher werden mit swap(A[j-1],A[j]); die beiden Elemente vertauscht. Auf diese Weise wandert das kleinste Element des Arrays ganz nach vorne auf Position 1. Diese Position muss im nächsten Durchlauf nicht mehr betrachtet werden, daher können wir schon bei 3 aufhören (in diesem Durchlauf wandert dann das zweitkleinste Element auf Position 2)
Sind diese Inline-Delphi-Tags nicht klasse?
_________________
We are, we were and will not be.