Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Busquedad Pascal
program Busquedad(input,output); type vector = array [1..50] of integer; var v:vector; flag:boolean; primero,ultimo,q,central,p:integer; begin for q:=1 to 50 do begin write(q,' .- '); readln(v[q]) end; for q:=1 to 50 do begin primero:=q+1; for primero:=primero to 50 do begin if v[primero] < v[q] then begin ultimo:= v[primero]; v[primero]:=v[q]; v[q]:=ultimo end end end; flag:= false; primero:=1; ultimo:=50; write('Introduce Elemento a buscar: '); readln(q); while (primero <= ultimo) and (flag = false) do begin central:= (primero+ultimo) div 2; if q = v[central] then flag:= true else if q > v[central] then primero:=central+1 else ultimo:=central-1; end; if flag = true then p:=central else p:=0; if (p = central) then writeln('Elemento buscado en la posicion ',p) else writeln('Elemento no existente '); end.
run
|
edit
|
history
|
help
0
Бассейн-5
Моделирование div mod
1januar2018
Решето Эратосфена
fini
Data fb Akanshapanchal2000@gmail.com
3
janja - naloga 1 - 25.1.2012
Грицанова, стр. 26, Пример 1.7
aefrt