Jump to content
Fórum Script Brasil
  • 0

Ajuda simples fortran


Timbalactu

Question

Oi pessoa estou com um problema que não estou conseguindo identificar ou resolver, preciso gerar vários números aleatórios entre 0 e 1 e se esses numeros forem > 0.5 então minha variável se igual a -1 e se forem menores se iguala a 1 entretando algo esta dando errado o código que fiz é esse:

program valor_medio

!----------------------------------------------------------------------
Implicit none
Real N1(10), N2(100)
Integer i, x1(10), x2(100)
!----------------------------------------------------------------------

print*,'GERANDO VARIÁVEIS ALEATÓRIAS'

print*,'-> Para 10 variáveis'
call random_number(N1)

do i=1,10
if (N1(i).lt.0.5) then
(x1(i).eq.1)
else if (N1(i).ge.0.5) then
(x1(i) = -1)
end if

write(*,*) x1(i)
end do

end program

Link to comment
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Forum Statistics

    • Total Topics
      152.2k
    • Total Posts
      652k
×
×
  • Create New...