pascal程序中记录类型中能否出现string
TYPExx=string;date=RECORDyear:integer;mounth:1..12;day:1..31;END;student=RECORDnum:in...
TYPE
xx=string;
date=RECORD
year:integer;
mounth:1..12;
day:1..31;
END;
student=RECORD
num:integer;
birthday:date;
marridate:date;
CASE sex:xx of
'1':(n:integer);
'2':(ok:string);
END;
VAR
a:student;
BEGIN
WITH a,birthday do
BEGIN
num:=12345;
year:=2012;
mounth:=12;
day:=21;
WITH marridate do
BEGIN
year:=1999;
mounth:=11;
day:=2;
END;
readln (sex);
CASE sex of
'1':read (n);
'2':read (ok);
END;
END;
WITH a,birthday do
BEGIN
writeln (num,' ',year,' ',mounth,' ',day);
WITH marridate do
writeln (year,' ',mounth,' ',day);
CASE sex of
'1':write (n);
'2':write (ok);
END;
END;
END.
但是改成这样却能运行
TYPE
date=RECORD
year:integer;
mounth:1..12;
day:1..31;
END;
student=RECORD
num:integer;
birthday:date;
marridate:date;
CASE sex:integer of
1:(n:integer);
2:(ok:string);
END;
VAR
a:student;
BEGIN
WITH a,birthday do
BEGIN
num:=12345;
year:=2012;
mounth:=12;
day:=21;
WITH marridate do
BEGIN
year:=1999;
mounth:=11;
day:=2;
END;
readln (sex);
CASE sex of
1:read (n);
2:read (ok);
END;
END;
WITH a,birthday do
BEGIN
writeln (num,' ',year,' ',mounth,' ',day);
WITH marridate do
writeln (year,' ',mounth,' ',day);
CASE sex of
1:write (n);
2:write (ok);
END;
END;
END.
试问一楼:为什么? 展开
xx=string;
date=RECORD
year:integer;
mounth:1..12;
day:1..31;
END;
student=RECORD
num:integer;
birthday:date;
marridate:date;
CASE sex:xx of
'1':(n:integer);
'2':(ok:string);
END;
VAR
a:student;
BEGIN
WITH a,birthday do
BEGIN
num:=12345;
year:=2012;
mounth:=12;
day:=21;
WITH marridate do
BEGIN
year:=1999;
mounth:=11;
day:=2;
END;
readln (sex);
CASE sex of
'1':read (n);
'2':read (ok);
END;
END;
WITH a,birthday do
BEGIN
writeln (num,' ',year,' ',mounth,' ',day);
WITH marridate do
writeln (year,' ',mounth,' ',day);
CASE sex of
'1':write (n);
'2':write (ok);
END;
END;
END.
但是改成这样却能运行
TYPE
date=RECORD
year:integer;
mounth:1..12;
day:1..31;
END;
student=RECORD
num:integer;
birthday:date;
marridate:date;
CASE sex:integer of
1:(n:integer);
2:(ok:string);
END;
VAR
a:student;
BEGIN
WITH a,birthday do
BEGIN
num:=12345;
year:=2012;
mounth:=12;
day:=21;
WITH marridate do
BEGIN
year:=1999;
mounth:=11;
day:=2;
END;
readln (sex);
CASE sex of
1:read (n);
2:read (ok);
END;
END;
WITH a,birthday do
BEGIN
writeln (num,' ',year,' ',mounth,' ',day);
WITH marridate do
writeln (year,' ',mounth,' ',day);
CASE sex of
1:write (n);
2:write (ok);
END;
END;
END.
试问一楼:为什么? 展开
3个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询