#10784: wts wrong?pascal


Trickster (Trickster)

學校 : 迦密中學
編號 : 56818
來源 : [218.188.218.85]
最後登入時間 :
2016-03-22 16:01:12
a006. 一元二次方程式 | From: [202.140.108.126] | 發表日期 : 2016-03-15 22:46

program untitled;
var
a,b,c:real; delta:real;ans1,ans2:real;
begin
writeln( 'please input a');
readln(a);
writeln('please input b');
readln(b);
writeln('please input c');
readln(c);
delta :=(b*b-4*a*c);
if a=0 then
writeln('not a qudratic equation')
else if delta<0  then
writeln('no real root')
else if delta>=0  then
begin
ans1 := ((b*(-1)+sqrt(delta))/(2*a));
ans2 := ((b*(-1)-sqrt(delta))/(2*a));
if delta>0 then
writeln('Two different real root x1=',ans1:0 ,' x2=',ans2:0)
else if delta=0 then
writeln('Two same real root x=', ans1:0)
end;
end.

 
ZeroJudge Forum