早教吧 育儿知识 作业答案 考试题库 百科 知识分享

请告诉我哪里错了,如何纠正,错误提示是什么意思?reala,b,c,d,e,f,g,area,tarearead*,a,b,c,d,e,f,garea=tarea(a,e,f)+tarea(d,f,g)+tarea(b,c,g)write(*,*)areaccontainsfunctiontarea(a,b,c)reala,b,c,p,ta

题目详情
请告诉我哪里错了,如何纠正,错误提示是什么意思?
real a,b,c,d,e,f,g,area,t_area
read*, a,b,c,d,e,f,g
area=t_area(a,e,f)+t_area(d,f,g)+t_area(b,c,g)
write(*,*) area
c
contains
function t_area(a,b,c)
real a,b,c,p,t_area
p=(a+b+c)/2
t_area=sqrt(p*(p-a)*(p-b)*(p-c))
end function t_area
end
Compiling Fortran...
C:\Program Files\Microsoft Visual Studio\Common\MSDev98\My Projects\5.for
C:\Program Files\Microsoft Visual Studio\Common\MSDev98\My Projects\5.for(7) : Error: The name of the internal procedure conflicts with a name in the encompassing scoping unit. [T_AREA]
function t_area(a,b,c)
---------------^
Error executing df.exe.
▼优质解答
答案和解析
问题出在t_area的声明,你重复声明了两次:
real a,b,c,d,e,f,g,area,t_area
real a,b,c,p,t_area
把第一个删掉即可:
program test
implicit none
real a,b,c,d,e,f,g,area
read*,a,b,c,d,e,f,g
area=t_area(a,e,f)+t_area(d,f,g)+t_area(b,c,g)
write(*,*) area
pause
contains
function t_area(a,b,c)
real a,b,c,p,t_area
p=(a+b+c)/2
t_area=sqrt(p*(p-a)*(p-b)*(p-c))
end function t_area
end program test