为什么在Fortran中会出现这些错误,比如1处的不可分类语句和意外垃圾等?
我刚开始使用Fortran,并试图编写一个基本程序,但却遇到了很多我不理解的错误。请检查以下内容。我提到了其他类似的问题,但没有用为什么在Fortran中会出现这些错误,比如1处的不可分类语句和意外垃圾等?,fortran,Fortran,我刚开始使用Fortran,并试图编写一个基本程序,但却遇到了很多我不理解的错误。请检查以下内容。我提到了其他类似的问题,但没有用 program roots real a,b,c real disc real root1,root2 write (*,*) , "Please provide a, b and c" read (*,*) ,a,b,c disc = b**2 -4.0*a*c if dis
program roots
real a,b,c
real disc
real root1,root2
write (*,*) , "Please provide a, b and c"
read (*,*) ,a,b,c
disc = b**2 -4.0*a*c
if disc < 0
print *,"No real roots"
else if disc = 0
print *,"Equal roots"
root1 = -b/2
print *,"root is :" ,root1
else
print *,"2 real roots"
2*root1 = -b + sqrt(b**2 - 4.0*a*c)
2*root2 = -b - sqrt(b**2 - 4.0*a*c)
print *,"root 1 is:" , root1
print *,"root 2 is:" , root2
end roots
你的代码中有许多错误 首先:始终使用
implicit none
,否则未定义的变量可能具有难以调试的隐式数据类型
您的如果。。如果
块有多个错误,则结束。比较两个代码
程序根
隐式无
真正的a,b,c
真实光盘
真正的根1,根2
打印*,“请提供a、b和c”
读(*,*)a、b、c
圆盘=b**2-4.0*a*c
如果(圆盘<0),则
打印*,“无实际根”
否则,如果(disc==0),则
打印*,“等根”
root1=-b/2
打印*,“根是:”,根1
其他的
打印*,“2个实根”
root1=(-b+sqrt(b**2-4.0*a*c))/2
root2=(-b-sqrt(b**2-4.0*a*c))/2
打印*,“根1为:”,根1
打印*,“根2为:”,根2
如果结束
结束程序