一元二次方程求根 fortranprogram mainwrite(*,*)"a="read(*,*)awrite(*,*)"b="read(*,*)bwrite(*,*)"c="read(*,*)creal::d,e,x1,x2d=b*b-4*a*ce=sqrt(d)x1=(-b+e)/2.0/ax2=(-b-e)/2.0/awrite(*,*)x1write(*,*)x2end这是小弟编的求根公式的程序,

来源:学生作业帮助网 编辑:六六作业网 时间:2024/12/26 13:02:31
一元二次方程求根fortranprogrammainwrite(*,*)"a="read(*,*)awrite(*,*)"b="read(*,*)bwrite(*,*)"c="read(*,*)cre

一元二次方程求根 fortranprogram mainwrite(*,*)"a="read(*,*)awrite(*,*)"b="read(*,*)bwrite(*,*)"c="read(*,*)creal::d,e,x1,x2d=b*b-4*a*ce=sqrt(d)x1=(-b+e)/2.0/ax2=(-b-e)/2.0/awrite(*,*)x1write(*,*)x2end这是小弟编的求根公式的程序,
一元二次方程求根 fortran
program main
write(*,*)"a="
read(*,*)a
write(*,*)"b="
read(*,*)b
write(*,*)"c="
read(*,*)c
real::d,e,x1,x2
d=b*b-4*a*c
e=sqrt(d)
x1=(-b+e)/2.0/a
x2=(-b-e)/2.0/a
write(*,*)x1
write(*,*)x2
end
这是小弟编的求根公式的程序,不考虑虚根,能告诉一下错误在哪吗?老说有一个error~

一元二次方程求根 fortranprogram mainwrite(*,*)"a="read(*,*)awrite(*,*)"b="read(*,*)bwrite(*,*)"c="read(*,*)creal::d,e,x1,x2d=b*b-4*a*ce=sqrt(d)x1=(-b+e)/2.0/ax2=(-b-e)/2.0/awrite(*,*)x1write(*,*)x2end这是小弟编的求根公式的程序,
real::d,e,x1,x2 要放在所有可执行语句之前.
write(*,*)"a=" 引号要用单引号.