主题:求助
今天在编一个记录类型的数组时候,其中用到字符紧缩数组packed array,结果发现对该数组无法进行读的操作,望哪位大狭给予支持帮助,感激不尽。
程序如下:
program t;
const n=4;
type a=packed array[1..15]of char;
stu=record
name:a;
score:real;
grade:char;
end;
studenta=array[1..n]of stu;
var students:studenta;
ave:real;
i:integer;
begin
for i:=1 to n do
with students[i] do
readln(score,name); 编译到这里提示“该类型不能这样读”
ave:=0;
for i:=1 to n do
ave:=ave+students[i].score;
ave:=ave/n;
write('name score grade ');
writeln;
for i:=1 to n do
with students[i] do
begin
if score>=ave then grade:='A' else
if score>=ave-10 then grade:='B' else
grade:='C';
writeln(name,' ',score:2:2,' ',grade:2);
end;
end.
程序如下:
program t;
const n=4;
type a=packed array[1..15]of char;
stu=record
name:a;
score:real;
grade:char;
end;
studenta=array[1..n]of stu;
var students:studenta;
ave:real;
i:integer;
begin
for i:=1 to n do
with students[i] do
readln(score,name); 编译到这里提示“该类型不能这样读”
ave:=0;
for i:=1 to n do
ave:=ave+students[i].score;
ave:=ave/n;
write('name score grade ');
writeln;
for i:=1 to n do
with students[i] do
begin
if score>=ave then grade:='A' else
if score>=ave-10 then grade:='B' else
grade:='C';
writeln(name,' ',score:2:2,' ',grade:2);
end;
end.