Nine-link algorithm (PASCAL) recursive realization

xiaoxiao2021-03-06  57

Program jlh (Input, Output);

VAR

K, S, I, J, Total: Integer;

Procedure Move (N: Integer; Var S: Integer);

VAR

J, I: integer;

Begin

IF (n = 1) OR (n = 2)

Then S: = S 1

Else Begin

For i: = 1 to n-2 do

Move (i, s);

S: = S 1;

For J: = 1 to N-2 DO

Move (J, S)

End

END;

Begin

K: = 0;

Write ('INPUT TOTAL =');

Read (Total);

Move (Total, K);

Writeln;

Writeln ('s =', k)

End.

转载请注明原文地址:https://www.9cbs.com/read-113795.html

New Post(0)