Difference between revisions of "F90: Tabela verdade do OU Exclusivo"

From AdonaiMedrado.Pro.Br
Jump to: navigation, search
(New page: <code lang="fortran"> PROGRAM aula LOGICAL :: l1, l2 l1=.TRUE. l2=.TRUE. WRITE (*,*) "T e T =", ExecutarOUExclusivo(l1,l2) WRITE (*,*) "T e F =", ExecutarOUExclusivo(l1,.NOT. l2) WRI...)
(No difference)

Revision as of 17:16, 2 October 2008

PROGRAM aula
	LOGICAL :: l1, l2
	l1=.TRUE.
	l2=.TRUE.
	WRITE (*,*) "T e T =", ExecutarOUExclusivo(l1,l2)
	WRITE (*,*) "T e F =", ExecutarOUExclusivo(l1,.NOT. l2)
	WRITE (*,*) "F e T =", ExecutarOUExclusivo(.NOT. l1, l2)
	WRITE (*,*) "F e F =", ExecutarOUExclusivo(.NOT. l1,.NOT. l2)
CONTAINS
	LOGICAL FUNCTION ExecutarOUExclusivo(x,y)
		LOGICAL, INTENT(IN) :: x,y
		!Formas de se escrever um OU Exclusivo:
		!(x .AND. .NOT. y) .OR. (.NOT x .AND. y)
		!ou
		!(x .OR. y) .AND. (.NOT. x .OR. .NOT. y)
		!ou
		!(x .OR. y) .AND. .NOT. (x .AND. y)
		!ou
		!.NOT. ((x .OR. .NOT. y) .AND. (.NOT. x .OR. y))
		!Usarei aqui a primeira forma.
		ExecutarOUExclusivo = (x .AND. .NOT. y) .OR. (.NOT x .AND. y)
	END FUNCTION ExecutarOUExclusivo
END PROGRAM aula