level 2
沥沥小雨的梦
楼主
题目:求方程的解(简化版)
输入a、b、c求一元二次方程ax^2+bx+c=0的两个实数根(不考虑无解的情况)。
输入:一行,为a,b,c,每个数用空格隔开。
输出:共一行,两个方程的解用一个空格隔开,保留2位小数,先输出较大的解,若两个解相等时也要输出两个相等的数。
var
a,b,c,d,e:integer;
begin
read(a,b,c);
d:=(-b+sqrt(b*b-4*a*c))/2a;
e:=(-b-sqrt(b*b-4*a*c))/2a;
write(d:0:2,' ',e:0:2);
end.
错误显示:
Free Pascal Compiler version 2.6.4+dfsg-4 [2014/10/14] for x86_64
Copyright (c) 1993-2014 by Florian Klaempfl and others
Target OS: Linux for x86-64
Compiling Main.pas
Main.pas(5,24) Error: Incompatible types: got "Extended" expected "SmallInt"
Main.pas(5,26) Fatal: Syntax error, ";" expected but "identifier A" found
Fatal: Compilation aborted
Error: /usr/bin/ppcx64 returned an error exitcode (normal if you did not specify a source file to be compiled)
2016年07月07日 11点07分
1
输入a、b、c求一元二次方程ax^2+bx+c=0的两个实数根(不考虑无解的情况)。
输入:一行,为a,b,c,每个数用空格隔开。
输出:共一行,两个方程的解用一个空格隔开,保留2位小数,先输出较大的解,若两个解相等时也要输出两个相等的数。
var
a,b,c,d,e:integer;
begin
read(a,b,c);
d:=(-b+sqrt(b*b-4*a*c))/2a;
e:=(-b-sqrt(b*b-4*a*c))/2a;
write(d:0:2,' ',e:0:2);
end.
错误显示:
Free Pascal Compiler version 2.6.4+dfsg-4 [2014/10/14] for x86_64
Copyright (c) 1993-2014 by Florian Klaempfl and others
Target OS: Linux for x86-64
Compiling Main.pas
Main.pas(5,24) Error: Incompatible types: got "Extended" expected "SmallInt"
Main.pas(5,26) Fatal: Syntax error, ";" expected but "identifier A" found
Fatal: Compilation aborted
Error: /usr/bin/ppcx64 returned an error exitcode (normal if you did not specify a source file to be compiled)