fortran编程错误?

2024-11-29 02:51:25
推荐回答(1个)
回答(1):

你的fortran程序有两处问题,

1len=11写成了len-11

2weekday写成了weekend

完整的程序如下(改动的地方见注释)

PROGRAM weekday_weekend

IMPLICIT NONE

CHARACTER(len=11)::c_day

CHARACTER(len=11)::c_type  !这里把(len-11)改成(len=11)

WRITE(*,*)'Enter the name of the day:'

READ(*,*)c_day

SELECT CASE(c_day)

CASE('Monday','Tuesday','Wednesday','Thursday','Friday')

c_type='Weekday' !这里把Weekend改成Weekday

CASE('Saturday','Sunday')

c_type='Weekend'

CASE DEFAULT

c_type='Invalid day'

END SELECT

WRITE(*,*)'Day Type=',c_type

END PROGRAM weekday_weekend