1
您好,我已经阅读了3位数月份缩写和一天的文件输入任务,并且我必须计算每个日期的Julian日期(自1月1日) 无论我在添加两个INTEGERS时做什么,我都会收到错误201(不兼容的数据类型)。我试图制作一个新程序并使其运行,但是一旦将其实施到现有代码中,它就不再适用了。这很令人沮丧,请帮助。我厌倦了这个愚蠢的班级,使我无法在网上找到狗狗帮助的语言。 下面是代码:将常量字符串添加到变量时的运行时错误201 PASCAL
program prg6_150;
const
MONABV:array[1..12] of string[03] = ('JAN','FEB','MAR','APR','MAY','JUN',
'JUL','AUG','SEP','OCT','NOV','DEC');
MONDAYS:array[1..12] of integer = (31,28,31,30,31,30,31,31,30,31,30,31);
var
more_rec:Boolean; { EOF flag }
DAY:integer; { input day }
MONTH:string[03]; { input month abbreviation }
JULIAN:integer; { computed Julian day }
ch:char; { spacer character for input }
FileIn:Text;
FileOut:Text;
{ your module, to be called "JULIAN_DAY" inserted here }
procedure JULIAN_DAY;
var
j,sum_days:integer;
begin
j := 0;
sum_days := 0;
if MONTH = 'JAN' then j := 1 else
if MONTH = 'FEB' then j := 2 else
if MONTH = 'MAR' then j := 3 else
if MONTH = 'APR' then j := 4 else
if MONTH = 'MAY' then j := 5 else
if MONTH = 'JUN' then j := 6 else
if MONTH = 'JUL' then j := 7 else
if MONTH = 'AUG' then j := 8 else
if MONTH = 'SEP' then j := 9 else
if MONTH = 'OCT' then j := 10 else
if MONTH = 'NOV' then j := 11 else
if MONTH = 'DEC' then j := 12;
for J:= 2 to 12 do
repeat
sum_days := MONDAYS[1] + sum_days;
j := j - 1
until j = 1;
Julian := DAY + sum_days;
end;
procedure read_rec;
begin
if Eof(FileIn) then
more_rec := False
else
readln(FileIn,day,ch,month)
end; { read_rec }
procedure initialize;
begin
more_rec := True;
Assign(FileIn,'JULIAN.DAT');
Reset(FileIn);
Assign(FileOut,'JULIAN.OUT');
Rewrite(FileOut);
read_rec
end; { initialize }
procedure process;
begin
Julian_Day;
writeln(FileOut,day:2,' ',month,' ',julian:3);
read_rec
end; { process }
procedure wrapup;
begin
Close(FileOut);
Close(FileIn)
end; { wrapup }
begin { main }
initialize;
while more_rec do
process;
wrapup
end.
MONDAYS [1]通常是MONDAYS [j-1],我暂时编辑尝试,它仍然给我一个类型错误hurr durr –