На второе задание: program sortArray; var arrayA:array[1..50] of real; bufR:real; n,ci,cIi,stOt,most:byte; begin readln(n); for ci:=1 to n do readln(arrayA[ci]); for ci:=1 to n-1 do begin most:=0; for cIi:=ci to n do if (arrayA[cIi]>=0) and ((arrayA[cIi]<arrayA[most]) or (most=0)) then most:=cIi; if most<>0 then begin bufR:=arrayA[ci]; arrayA[ci]:=arrayA[most]; arrayA[most]:=bufR; end else begin stOt:=ci; break; end; end; for ci:=1 to n-stOt do begin most:=stOt+ci-1; for cIi:=stOt+ci to n do if arrayA[cIi]>arrayA[most] then most:=cIi; bufR:=arrayA[stOt+ci-1]; arrayA[stOt+ci-1]:=arrayA[most]; arrayA[most]:=bufR; end; writeln; for ci:=1 to n do writeln(arrayA[ci]:0:3); readln; end.
На второе задание: program sortArray; var arrayA:array[1..50] of real; bufR:real; n,ci,cIi,stOt,most:byte; begin readln(n); for ci:=1 to n do readln(arrayA[ci]); for ci:=1 to n-1 do begin most:=0; for cIi:=ci to n do if (arrayA[cIi]>=0) and ((arrayA[cIi]<arrayA[most]) or (most=0)) then most:=cIi; if most<>0 then begin bufR:=arrayA[ci]; arrayA[ci]:=arrayA[most]; arrayA[most]:=bufR; end else begin stOt:=ci; break; end; end; for ci:=1 to n-stOt do begin most:=stOt+ci-1; for cIi:=stOt+ci to n do if arrayA[cIi]>arrayA[most] then most:=cIi; bufR:=arrayA[stOt+ci-1]; arrayA[stOt+ci-1]:=arrayA[most]; arrayA[most]:=bufR; end; writeln; for ci:=1 to n do writeln(arrayA[ci]:0:3); readln; end.
a i a-i
10 - 0 = 10
10 - 1 = 9
9 - 2 = 7
7 - 3 = 4
4 - 4 = 0
ответ: 0