Pascal/Turbo Pascal - necesito traducción al pascal!!!

 
Vista:

necesito traducción al pascal!!!

Publicado por Amanda (3 intervenciones) el 27/04/2004 14:56:20
Tengo un algoritmo, creo está en Ada, necesito llevarlo al Pasca, ya que algunas sentencias (como el discrete, new) no las puedo encontrar en un tutorial. Aquí va:
1 function fibonacci_search(item: integer; arr: sort_array) return index
2 is
3 l : index := arr'first; -- first element of array
4 u : index := arr'last; -- last element of array
5 m : index := (u+l)/2;
6 x,a,b : integer;
7 begin
8 a := (Fn-3);
9 b := (Fn-2)-(Fn-3);
10 discrete (f2,f1) := (Fn-2,Fn-3)
11 new (f2,f1) := (f2-f1,2*f1-f2) | (a,b)
12 with i := u-l+1
13 new i=i/2 loop
14 loop
15 if item < arr(m) then
16 m := m-f1; -- compute new position of compared element
17 f2 := f2-f1;
18 f1 := f1-f2;
19 elsif item > arr(m) then
20 m := m+f1; -- compute new position of compared element
21 x := f1;
22 f1 := f2-f1;
23 f2 := x;
24 a := f2; b := f1;
25 else
26 return m; -- return index of found item
27 end if;
28 i := i/2;
29 end loop;
30 end fibonacci_search;
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder