主题:过程和函数
xx小小迷
[专家分:80] 发布于 2008-05-21 22:03:00
编写一个根据三角形的周长求面积的函数area(程序都打上去)。
回复列表 (共2个回复)
沙发
angwuy [专家分:2280] 发布于 2008-05-22 07:02:00
function area(a,b,c:extended):extended;
var s:extended;
begin
s:=(a+b+c)/2;
area:=sqrt(s*(s-a)*(s-b)*(s-c));
end;
板凳
Mato完整版 [专家分:1270] 发布于 2008-05-23 22:02:00
楼上在使用EXTENDED类型时忘了{$N+}了吧!
{$N+}
TYPE
{Integer type declare}
I_ = INTEGER;
SI_ = SHORTINT;
LI_ = LONGINT;
BI_ = BYTE;
WI_ = WORD;
{Real type declare}
R_ = REAL;
SR_ = SINGLE;
DR_ = DOUBLE;
ER_ = EXTENDED;
CR_ = COMP;
{Other type declare}
C_ = CHAR;
B_ = BOOLEAN;
S_ = STRING;
FUNCTION area(a1, a2, a3: ER_): ER_;
VAR s: ER_;
BEGIN
s := (a1 + a2 + a3) / 2;
area := SQRT(s * (s - a1) * (s - a2) * (s - a3));
END;
{Main procedure}
VAR i, j, k: ER_;
BEGIN
READLN(i, j, k);
WRITELN(area(i, j, k):1 :5);
END.
我来回复