I just decided a couple of days ago to start a daily “programming gym” session, to keep my programming skills sharp, since otherwise there are long periods of time in which I don’t do any programming, and the “trade” suffers.
Languages to practice will vary, but at present the focus will be in Fortran. And the problems to solve will come from Sphere Online Judge.
PROGRAM ABSYS
IMPLICIT NONE
CHARACTER :: mas, igual
CHARACTER (LEN=50) :: dato1,dato2,resultado
INTEGER :: sets,count,idato1,idato2,iresultado
READ*, sets
DO count=1,sets
READ*, dato1,mas,dato2,igual,resultado
CALL convert(dato1,idato1)
CALL convert(dato2,idato2)
CALL convert(resultado,iresultado)
IF (idato1 .EQ. -1) WRITE(*,’(I0,A,I0,A,I0)’) iresultado-idato2, ” + “, idato2, ” = “, iresultado
IF (idato2 .EQ. -1) WRITE(*,’(I0,A,I0,A,I0)’) idato1, ” + “, iresultado-idato1, ” = “, iresultado
IF (iresultado .EQ. -1) WRITE(*,’(I0,A,I0,A,I0)’) idato1, ” + “, idato2, ” = “, idato1+idato2
END DO
CONTAINS
SUBROUTINE convert(dato,idato)
CHARACTER (LEN=*) :: dato
INTEGER :: idato, pos
pos = INDEX(dato,”machula”)
IF (pos .EQ. 0) THEN
READ (dato,’(I50)’), idato
ELSE
idato = -1
END IF
END SUBROUTINE convert
END PROGRAM ABSYS