Add all the A tasks
This commit is contained in:
parent
2dd7375f96
commit
051504d65b
1608 changed files with 18584 additions and 0 deletions
|
|
@ -0,0 +1,33 @@
|
|||
program Movavg
|
||||
implicit none
|
||||
|
||||
integer :: i
|
||||
|
||||
write (*, "(a)") "SIMPLE MOVING AVERAGE: PERIOD = 3"
|
||||
|
||||
do i = 1, 5
|
||||
write (*, "(a, i2, a, f8.6)") "Next number:", i, " sma = ", sma(real(i))
|
||||
end do
|
||||
do i = 5, 1, -1
|
||||
write (*, "(a, i2, a, f8.6)") "Next number:", i, " sma = ", sma(real(i))
|
||||
end do
|
||||
|
||||
contains
|
||||
|
||||
function sma(n)
|
||||
real :: sma
|
||||
real, intent(in) :: n
|
||||
real, save :: a(3) = 0
|
||||
integer, save :: count = 0
|
||||
|
||||
if (count < 3) then
|
||||
count = count + 1
|
||||
a(count) = n
|
||||
else
|
||||
a = eoshift(a, 1, n)
|
||||
end if
|
||||
|
||||
sma = sum(a(1:count)) / real(count)
|
||||
end function
|
||||
|
||||
end program Movavg
|
||||
Loading…
Add table
Add a link
Reference in a new issue