Difference between revisions of "F90: Introdução às FUNCTIONs"
From AdonaiMedrado.Pro.Br
(New page: <code lang="fortran"> PROGRAM aula INTEGER :: Opcao LOGICAL :: a,b DO WRITE (*,*) "1 - E" WRITE (*,*) "2 - OU" WRITE (*,*) "3 - OU Exclusivo" WRITE (*,*) "4 - Sair" READ (*,*...) |
(No difference)
|
Latest revision as of 16:56, 2 October 2008
PROGRAM aula INTEGER :: Opcao LOGICAL :: a,b DO WRITE (*,*) "1 - E" WRITE (*,*) "2 - OU" WRITE (*,*) "3 - OU Exclusivo" WRITE (*,*) "4 - Sair" READ (*,*) Opcao IF (Opcao >=1 .AND. Opcao <= 3 ) THEN WRITE (*,*) "Digite uma variavel logica" READ (*,*) a WRITE (*,*) "Digite outra variavel logica" READ (*,*) b IF (Opcao == 1) THEN WRITE (*,*) "Resultado = ",ExecutarE(a,b) ELSE IF (Opcao == 2) THEN WRITE (*,*) "Resultado = ",ExecutarOU(a,b) ELSE IF (Opcao == 3) THEN WRITE (*,*) "Resultado = ",ExecutarOUExclusivo(a,b) END IF ELSE IF (Opcao == 4) THEN EXIT END IF END DO CONTAINS LOGICAL FUNCTION ExecutarE(x,y) LOGICAL, INTENT(IN) :: x,y ExecutarE = x .AND. y END FUNCTION ExecutarE LOGICAL FUNCTION ExecutarOU(x,y) LOGICAL, INTENT(IN) :: x,y ExecutarOU = x .OR. y END FUNCTION ExecutarOU LOGICAL FUNCTION ExecutarOUExclusivo(x,y) LOGICAL, INTENT(IN) :: x,y ExecutarOUExclusivo = .NOT. ((x .OR. .NOT. y) .AND. (.NOT. x .OR. y)) END FUNCTION ExecutarOUExclusivo END PROGRAM aula