View Single Post
max2112
#1
Feb21-12, 05:26 PM
P: 1
I was given an assignment to create a program that solves the Josephus Problem ([URL="http://en.wikipedia.org/wiki/Josephus_problem"]. the program needs to work for n amount of people, and it must use an array.

Problem:
I need to create a subroutine that will allow the user to read(*,*) n
and create an array that is n big.

Attempt:

subroutine sub(n)
implicit none
integer :: n, i
integer :: array(n)
do i = 1, n
array(i) = 0
end do
end subroutine sub

program arrays
implicit none

integer :: size, i
write(*,*) "how big is your array"
read(*,*) size
call sub(size)



end program arrays

I am stuck, and dont know why this isnt working.
Attached Files
File Type: pdf *** 3.pdf (25.4 KB, 3 views)
Phys.Org News Partner Science news on Phys.org
World's largest solar boat on Greek prehistoric mission
Google searches hold key to future market crashes
Mineral magic? Common mineral capable of making and breaking bonds