2015-10-06 742 views
-1

我在Fortran语言很新的,我坚持下面的程序使用二次方程根找到。Fortran语言的sqrt()错误

它显示了以下错误:

d = sqrt(bsq \xE2\x80\x93 ac4) 1 Error: Syntax error in argument list at (1)

program quadratic 
implicit none 
real :: a, b, c, root1, root2 
real :: bsq, ac4, d 
print *, 'Please enter the coefficients a, b, and c as real numbers' 
read *, a, b, c 
bsq = b*b 
ac4 = 4*a*c 
if (bsq < ac4) then 
d = sqrt(bsq – ac4) 
root1 = (-b+d)/(2*a) 
root2 = (-b+d)/(2*a) 
print *, 'The real roots are ', root1, root2 
else if (root1==root2) then 
root1 = root2 
print *, 'There is one real root which is ', root1 
else 
print *, 'There are no real roots' 
end if 
end program quadratic 
+0

谢谢大家,问题解决了 – KBnd

回答

1

你需要bsqac4,而不是一个破折号之间的减号。仔细观察。

减号: -
         短跑: -