Skip to content

Instantly share code, notes, and snippets.

@zrhans
Created May 29, 2021 14:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zrhans/af6fe6e3e551e77a9cf5236153e65c78 to your computer and use it in GitHub Desktop.
Save zrhans/af6fe6e3e551e77a9cf5236153e65c78 to your computer and use it in GitHub Desktop.
program canhao
implicit none
integer, parameter :: r = 10 ! Alcance máximo a borda de um círculo de raio r (r = 10 Km)
integer :: x, y
real :: distancia
! Equação de um círculo de Raio r: x^2 + y^2 <= r^2
print *, 'Digite as coordenadas x e y: '
read *, x, y
! Testa se estas coordenadas ficam dentro do circulo
if ((x ** 2. + y ** 2.) .LE. r ** 2) then
print *, 'Acertou o Alvo'
! Calcula a distancia
distancia = SQRT(x ** 2. + y ** 2.)
print *, 'Distancia entre o canhao e o Alvo (Km): ', distancia
else
print *, 'Errou o Alvo!'
endif
end program canhao
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment