Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- procedure SelectionSort(const N: Integer; var A: TArr);
- var
- i, j, Min: Integer;
- SwapsCounter, ComparesCounter: Integer;
- begin
- SwapsCounter := 0;
- ComparesCounter := 0;
- for i := 1 to N - 1 do // Цикл S1
- begin
- Min := i;
- for j := i + 1 to N do // Цикл S2
- begin
- if A[j] < A[Min] then
- Min := j;
- Inc(ComparesCounter, 1);
- end;
- Swap(A[i], A[Min]);
- Inc(SwapsCounter);
- end;
- Write(ComparesCounter:10, ' |', SwapsCounter:10, ' |');
- end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement