Unit bai1
Bài 1:
unit toan;
interface
function dtht(x,y,h:integer):real;
function sht(r:integer):real;
function uscln(x,y:integer):integer;
function ktnt(x:integer):boolean;
function fibo(n:integer):integer;
implementation
function dtht(x,y,h:integer):real;
dtht:=((x+y)*h)/2;
end;
function sht(r:integer):real;
sht:= pi*r*r;
end;
function uscln(x,y:integer):integer;
while x<>y do
if x> y then x:=x-y
else y:=y-x;
uscln:=x;
end;
function ktnt(x:integer):boolean;
var i:integer;
ktnt:=false;
for i:=2 to x-1 do
if x mod i=0 then exit;
ktnt:=x>1;
end;
function fibo(n:integer):integer;
if n<3 then fibo:=1
else fibo:=fibo(n-2)+fibo(n-1);
end;
end.
program sd_toan;
uses toan;
var i:integer;
writeln(uscln(9,3));
writeln(dtht(2,3,4):0:0);
writeln(sht(2):0:0);
if ktnt(5)=true then writeln('la so nt')
else writeln('ko la so nt');
write('day fibo:');
for i:=1 to 8 do
write(fibo(i):3);
readln;
end.
Bạn đang đọc truyện trên: AzTruyen.Top