program Project1; {$APPTYPE CONSOLE} uses SysUtils; //-------------for 语句实现---------------------------- const N = 8; var Fib: array[0..8] of Integer ; i:Integer; begin Fib[0] := 0; Fib[1] := 1; for i:=2 to N do Fib[i] :=Fib[i -1] + Fib[i -2]; for i := 0 to N do Writeln(Fib[i]); Readln; { TODO -oUser -cConsole Main : Insert code here } end. { //---------------------While....do语句实现 --------------------------------------------- const N = 8; var Fib: array[0..N] of Integer; i:Integer; begin Fib[0] :=0; Fib[1] :=1; i :=2; while i<=N do begin Fib[i] :=Fib[i -1] + Fib[i - 2]; Inc(i); end; //-------------------------------------------------------------- i:=0; while i <=8 do begin Writeln(Fib[i]); Inc(i); end; Readln; end. } //====<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< //====<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< { //----------------Repeat..until 语句实现---------------------------------------------------- const N = 8; var Fib: array[0..N] of Integer; i:Integer; begin Fib[0] :=0; Fib[1] :=1; i:=2; repeat Fib[i] :=Fib[i -1]+Fib[i -2]; Inc(i); until i >=N ; i:=0; repeat Writeln(Fib[i]); Inc(i); until i >=N; Readln; end. } //====<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< //====<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< { //----------------goto 语句实现---------------------------------------------------- const N = 8; var Fib: array[0..N] of Integer; i:Integer; label Sum, Applear, ends; begin Fib[0] :=0; Fib[1] :=1; i:=2; //--------------------------------- sum: Fib[i]:=Fib[i -1] + Fib[i -2]; inc(i); if i <= N then goto sum; //---------------------------------- i:=0; Applear: Writeln(Fib[i]); Inc(i); if i <=N then begin goto Applear; end else begin goto ends; end; ends: Readln; end. }

 

posted on 2012-05-23 22:55  BarneyX  阅读(223)  评论(0编辑  收藏  举报