我有一个程序应该告诉用户他们输入的温度是否绝对为零。如果确实是这样,那么他们应该看到“对你来说没有熵”,如果它更大,那么它应该告诉他们它们在 a0 之上有多远,但是我不断收到消息说我的 if 语句有错误,并且不知道在哪里首先,有人可以帮我吗?
PROGRAM Project2
CHARACTER(1):: tempType
REAL:: k, f, c
REAL:: temp
REAL:: answer
PRINT *, "What is the temperature type?"
READ *, tempType
PRINT *, "whats the temp?"
READ *, temp
k = 0.0
c = -273.15
f = -459.67
answer = getMinTemperature(tempType)
PRINT *, answer
CONTAINS
FUNCTION getMinTemperature(tempType)
REAL:: getMinTemperature
CHARACTER(1), INTENT(IN):: tempType
REAL:: temp
DO i = 1, num
IF(ACHAR(tempType(i)) <= temp .AND. k > temp) THEN
k= 0.0
getMinTemperature = k
EXIT
ELSE IF (c <= temp .AND. c > temp) THEN
c= -273.15
getMinTemperature = c
EXIT
ELSE IF ( f <= temp .AND. f > temp) THEN
f=-459.67
getMinTemperature = f
EXIT
END IF
END DO
END FUNCTION
END PROGRAM Project2