Fortran sqrt() 错误 [英] Fortran sqrt () error
本文介绍了Fortran sqrt() 错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是 Fortran 的新手,我坚持使用以下程序来使用二次方程求根.
I am very new in Fortran and I am stuck with the following program to find roots using quadratic equation.
显示以下错误:
d = sqrt(bsq xE2x80x93 ac4)1错误:(1) 处的参数列表中有语法错误
d = sqrt(bsq xE2x80x93 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
推荐答案
bsq
和 ac4
之间需要一个减号,而不是破折号.仔细看看.
You need a minus sign between bsq
and ac4
, not a dash. Look closely.
减号:-
破折号:–
Minus sign: -
Dash: –
这篇关于Fortran sqrt() 错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文