Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
binary_search-бинарный_поиск
{Двоичный (бинарный поиск)} const n = 4; var a: array[0..n] of integer; low, high, mid, d: integer; i: integer; begin for i := 0 to n do begin a[i] := 2*i+1; write (a[i], ' ') end; writeln; readln(d); low := 0; high := n; while low <= high do begin mid := (high + low) div 2; if a[mid] = d then begin writeln(mid); low := high; end else if a[mid] > d then high := mid-1 else low := mid+1 end; writeln (low, ' ', high) end.
run
|
edit
|
history
|
help
0
факторизация 2019
pares entre a y b
Enkripsi
digits_count
basketball_player_training
test30
TimeDemo
1
For6
Урок 3, задача 6 (1479). Без циклов