2015-10-06 111 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,而不是一個破折號之間的減號。仔細觀察。

減號: -
         短跑: -