回 帖 发 新 帖 刷新版面

主题:求助~~

program chengji;
type student=record
         num:integer;
         name:array[1..15]of char;
         sex:(male,female);
         age:5..100;
         score:real;
        end;
     studenta=array[1..10]of student;
     stfile=text of student;
var
  rf,f1,f2:stfile;
  students:studenta;
  stud:student;
  i,j:integer;
  ave1:real;
procedure print(var f:stfile);
begin
writeln('num':4,'name':10,'sex':8,'age':3,'score':5);
while not eof(f) do
  begin
   read(f,stud);
   with stud do
    begin
     write(num:4,name:10);
     if sex=male then write('male':8)
      else write('female':8);
     write(age:3,score:5:1);
    end;
writeln
  end;
end;
begin
assign(rf,'rfile');
assign(f1,'chengji.txt');
reset(rf);
rewrite(f1);
while not eof(rf) do
  while not eoln(rf) do
    for i:=1 to 10 do
      readln(rf,students[i]);
for i:=1 to 9 do
  for j:= i+1 to 10 do
   if (students[i].score<students[j].score)
    then begin
           stud:=students[i];
           students[i]:=students[j];
           students[j]:=stud;
        end;
ave1:=(students[1].score+students[2].score+students[3].score)/3;
ave2:=(students[9].score+students[8].score+students[10].score)/3;
for I:=1to 10 do
  writeln(f1,students[i]);
reset(f1);
print(f1);
close(rf);
close(f1)
end.


他说我是  100磁盘读错误
为什么~~~急啊

回复列表 (共4个回复)

沙发

没人学过文件类型么?

板凳

"stfile=text of student;"
这句话错了吧……

3 楼

楼上说得对,
  text类型是相当于"file of char"
  如果照楼主的逻辑,应为"file of student"
  "text of student"是无意义的

4 楼

但又有问题了~
我把他改成stfile=file of student
  还是100磁盘读错误

我来回复

您尚未登录,请登录后再回复。点此登录或注册