一個完整的程式範例

14 views
Skip to first unread message

sjgau02

unread,
Oct 27, 2007, 7:22:55 AM10/27/07
to NTUST_F90
! implicit none
real dtor
real x1, x2, y1a, y1b, y2a, y2b

x1= 60.0
x2= 45.0

y1a= sin(dtor(x1))
y1b= sqrt(3.0)/2.0

y2a= sin(dtor(x2))
y2b= 1.0/sqrt(2.0)

write(*, '(1x, 2f10.6)')y1a, y1b
write(*, '(1x, 2f10.6)')y2a, y2b
pause
! -----------------------------------------------

! swap the contents of y1a, y2a
call swap_real(y1a, y2a)
write(*, '(1x, 2f10.6)')y1a, y1b
write(*, '(1x, 2f10.6)')y2a, y2b

end
! -----------------------------------------------

subroutine swap_real(x, y)
implicit none
real x,y,z

z= x
x= y
y= z
end
! -----------------------------------------------

function dtor(d1)
implicit none
real dtor, d1

dtor= d1/180.0*(4.0*atan(1.0))
end
! -----------------------------------------------

Reply all
Reply to author
Forward
0 new messages