program main
real::x,dx,sum,fa,fb
integer::n
read(5,*) n
x=0.0
sum=0.0
dx=40.0/n
fa(x)=1.0/60.0*x**2 + 15.0
fb(x)=-0.3*x**2 + 18.0*x - 240.0
do i=1,n
x=x+dx
if (x<30) then
sum=dx*fa(x)+sum
else
sum=dx*fb(x)+sum
endif
enddo
write(6,*) sum
end
여기서 자꾸 fa랑 fb가 선언이 안됐다고 하는데 어케해야하져?
program annulus
double precision r, area, pi, a, b
parameter (pi = 3.1415926535897932D0)
area(r) = pi * r * r
print *, \"Enter the inner and outer radii of the annulus: \"
read *, a, b
write (*,10) \"The area of the annulus is \", area(b) - area(a)
10 format (a,f25.15)
end
졸래 찾아보다가 요걸 발견햇는데 이건 잘 돌아가던데.. 차이점이 뭔질 모르겠어요 ㅠㅠ 왜 밑에껀 돌아가고 위에껀 에러가 날까요 ㅠㅠ
위에꺼 리드문을 밑으로 내리니까 되네요.. 뭔차인지 -_-;