fortran小学生,请教各位这个fortran程序哪里不对,求解一元二次方程提示我Expected a right parenthesis in expression f=(-0.5*b/a,0.5*d/a)Expected a right parenthesis in expression g=(-0.5*b/a,0.5*d/a)programimplicit nonereal ::a,b

来源:学生作业帮助网 编辑:六六作业网 时间:2024/12/19 11:06:07
fortran小学生,请教各位这个fortran程序哪里不对,求解一元二次方程提示我Expectedarightparenthesisinexpressionf=(-0.5*b/a,0.5*d/a)E

fortran小学生,请教各位这个fortran程序哪里不对,求解一元二次方程提示我Expected a right parenthesis in expression f=(-0.5*b/a,0.5*d/a)Expected a right parenthesis in expression g=(-0.5*b/a,0.5*d/a)programimplicit nonereal ::a,b
fortran小学生,请教各位这个fortran程序哪里不对,求解一元二次方程
提示我Expected a right parenthesis in expression f=(-0.5*b/a,0.5*d/a)
Expected a right parenthesis in expression g=(-0.5*b/a,0.5*d/a)
program
implicit none
real ::a,b,c,d,e
complex f,g
print*,"please input a,b,c"
read*,a,b,c
d=abs(b*b-4*a*c)
e=sqrt(d)
f=(-0.5*b/a,0.5*e/a)
g=(-0.5*b/a,-0.5*e/a)
if (a/=0) then
print*,"one root is ",f
print*,"the other root is ",g
elseif ((a==0) .and.(b/=0)) then
print*," x=",-c/b
else
print*,"there are many roots"
endif
end program

fortran小学生,请教各位这个fortran程序哪里不对,求解一元二次方程提示我Expected a right parenthesis in expression f=(-0.5*b/a,0.5*d/a)Expected a right parenthesis in expression g=(-0.5*b/a,0.5*d/a)programimplicit nonereal ::a,b
program t !// Program 后面必须有名称,例如 t,不能是空的

implicit none

real :: a, b, c,d,e
complex f,g
print*, "please input a,b,c"
read*,a, b, c

d=abs(b*b-4*a*c)
e=sqrt(d)
f=cmplx(-0.5*b/a,0.5*e/a) !// 把两个数合成为复数,用 cmplx
g=cmplx(-0.5*b/a,-0.5*e/a) !// 同上
if (a/=0) then
print*, "one root is ", f
print*, "the other root is ", g
elseif ((a==0) .and. (b/=0)) then
print*, " x=", -c/b
else
print*, "there are many roots"
endif
end program