subroutine ShuffleArray1(array, N) implicit none integer, intent(in) :: N integer, intent(inout) :: array(N) integer :: i, j, temp real :: r ! Initialize the array with values from 1 to N ! do i = 1, N ! array(i) = i ! end do ! Shuffle the array using Fisher-Yates shuffle ! Call random_number(r) do i = N, 2, -1 Call random_number(r); Call random_number(r); Call random_number(r); j = 1 + int(i * r) !random()) ! Generate a random index between 1 and i temp = array(i) array(i) = array(j) array(j) = temp end do end subroutine ShuffleArray1 subroutine ShuffleArray(array, N) implicit none integer, intent(in) :: N integer, intent(inout) :: array(N) integer :: i, j, temp, M real :: random_values(N) integer :: seed(4) M=4 ! Set a new random seed using the current time call random_seed(size=M) call system_clock(count=seed(4)) seed = seed + int(N**2) call random_seed(put=seed) ! Generate an array of random values between 0 and 1 call random_number(random_values) ! Initialize the array with values from 1 to N do i = 1, N array(i) = i end do ! Shuffle the array using Fisher-Yates shuffle do i = N, 2, -1 j = 1 + int(i * random_values(i)) ! Generate a random index between 1 and i temp = array(i) array(i) = array(j) array(j) = temp end do end subroutine ShuffleArray program Main implicit none integer, parameter :: N = 10 integer :: myArray(N) integer :: i ! Initialize the array with values from 1 to N do i = 1, N myarray(i) = i end do ! Call the ShuffleArray subroutine call ShuffleArray1(myArray, N) ! Print the shuffled array print *, "Shuffled Array:" do i = 1, N print *, myArray(i) end do end program Main