free pascal问题,急~~~求教

来源:百度知道 编辑:UC知道 时间:2024/05/14 10:52:06
program ex2;
var
a,b,c,d,e,f,g:real;
g:boolean;
begin
writeln('please input chang du');
readln(a,b,c);
if (a>b) and (a>c) then d:=a e:=b f:=c else
if (b>a) and (b>c) then d:=b e:=a f:=c else
if (c>a) and (c>b) then d:=c e:=a f:=b;
g:=sqr(d)=sqr(e)+sqr(f);
if g:=true then writeln('shi')
else writeln('bu shi');
end.
在compile里显示有一个错误,可按了enter未显示错误。请高手帮忙!!

这句g:=sqr(d)=sqr(e)+sqr(f);
g不是boolean型么,怎么能这么写呢?
应该是if sqr(d)=sqr(e)+sqr(f) then g:=true else g:=false;吧

还有if g:=true then writeln('shi')
应该是if g=true then writeln('shi') 吧

另外,如果有a,b,c中有两个以上的数并列最大,下面这几句就有问题了,应该这样写
if (a>=b) and (a>=c) then begin d:=a;e:=b;f:=c;end else
if (b>=a) and (b>=c) then begin d:=b;e:=a;f:=c;end else
if (c>=a) and (c>=b) then begin d:=c;e:=a;f:=b;end

program dd;
var
a,b,c,d,e,f:integer;
g:boolean;
begin
g:=false;
writeln('please input chang du');
readln(a,b,c);
if (a>b) and (a>c)
then begin
d:=a;
e:=b;
f:=c;
end
else if (b>a) and (b>c)
then begin
d:=b;
e:=a;
f:=b;
end
else if (c>a) and (c>b)
then begin