自己编了一个Free Pascal程序,但运行时却提示错误,错误信息如下:
Fatal: Compilation aborted
程序如下(是一个解方程的程序):
program CET;
var
k:integer;
a,b,c,d,X1,X2:real;
begin
writeln('Welcome');
readln(k);
if k=2 then
begin
write('a=');
readln(a);
if a=0 then
begin
write('b=');
readln(b);
write('c=');
readln(c);
d:=-(c/b);
writeln('X=',d);
writeln('Thank you,Press Enter to Exit the Program');
readln;
halt;
end;
if a0 then
begin
write('b=');
readln(b);
write('c=');
readln(c);
d:=b*b-4*a*c;
if d0 then
begin
X1:=(-b+sqrt(d))/(2*a);
X2:=(-b-sqrt(d))/(2*a);
writeln('X1=',X1,',','X2=',X2);
writeln('Thank you,Press Enter to Exit the Program');
readln;
halt;
end;
if d=0 then
begin
X1:=(-b+sqrt(d))/(2*a);
writeln('X1=X2=',X1);
writeln('Thank you,Press Enter to Exit the Program');
readln;
halt;
end;
end;
end;
if k=1 then
begin
write('k=');
readln(b);
write('b=');
readln(c);
d:=-(c/b);
writeln('X=',d);
writeln('Thank you,Press Enter to Exit the Program');
readln;
halt;
end;
if k1 and k2 then
begin
writeln('Error');
writeln('Thank you,Press Enter to Exit the Program');
readln;
halt;
end;
end.
再次运行,错误信息又变了,变成:
calculate equation(s) tool.pas(69,7) Error: Incompatible types: got "Boolean" expected "LongInt"
calculate equation(s) tool.pas(76,6) Fatal: There were 1 errors compiling module, stopping
calculate equation(s) tool.pas(0) Fatal: Compilation aborted
|