宿題見てやるよ
■ このスレッドは過去ログ倉庫に格納されています
0113デフォルトの名無しさん
NGNG何度かリトライするのでオーダー不明。(テストでは3回リトライしていた。)
--------
var
median, midN, i, countS, countL: integer;
--------
begin
median := a[1];
midN := (N + 1) div 2;
i := 1;
repeat
if a[i] < median then
countS := countS + 1;
if a[i] > median then
countL := countL + 1;
if countS >= midN then
begin
median := a[i];
countS := 0;
countL := 0;
i := 1;
end;
if countL >= midN then
begin
median := a[i];
countS := 0;
countL := 0;
i := 1;
end;
i := i + 1;
until i > N;
writeln('Median = ', median);
end;
■ このスレッドは過去ログ倉庫に格納されています