{$apptype console}
program exp;
var total:integer;
procedure go(n:integer);
begin
if n>=1 then begin if n-1>0 then go(n-1) else total:=total+1; end;
if n>=2 then begin if n-2>0 then go(n-2) else total:=total+1; end;
end;
var
n:integer;
begin
write('n=');readln(n);
go(n);
writeln('Total=',total);
end.
程序在DELPHI下调试通过,TURBO PASCAL应该可以运行。
program aa;
var
a:array[1..1000] of longint;
i,j,n:longint;
begin
readln(n);
a[1]:=1; a[2]:=2;
for i:=3 to n do
a[i]:=a[i-1]+a[i-2];
write('total=',a[n]);
readln
end.