Đây là bài của em !
program bt1;uses crt;typest20=string[20];st10=string[10];sinhvien=recordht:st20;ns,qq:st10;dtb:real;xl:char;end;varf:file of sinhvien;fn:string;sv:sinhvien;bht:st20;i:word;beginclrscr;write('nhap vao ten file muon luu :');readln(fn);assign(f,fn);rewrite(f);i:=1;writeln('nhap thong tin ca nhan cua cac sinh vien :');repeatwrite('ho va ten cua sinh vien thu ',i,' :');readln(bht);if bht<>'' thenbeginsv.ht:=bht;write('nhap ngay thg (dd/yy/www) :');readln(sv.ns);write('nhap vao que quan :');readln(sv.qq);write('diem trung binh :');readln(sv.dtb);if sv.dtb<5 thensv.xl:='D'elseif sv.dtb<6.5 thensv.xl:='C'elseif sv.dtb<8 thensv.xl:='B'elsesv.xl:='A';write(f,sv); <==== chỗ này em chuyển thành writeln(f,sv); nó báo lỗi là:Error:Can't use readln or writeln on typed file (Tại khi in ra kết quả nó cứ in trên 1 dòng nên không đẹp )end;inc(i);until bht='';close(f);readln;end.>>Mà anh ơi thi tin THCS có cần học phần file không ạ ! Tại còn ít thời gian nên em chỉ ôn những mảng thi cho hiệu quả thôi ạ!
lỗi bài này nằm ở chỗ này
var
f:file of sinhvien;
mà sinhvien là một bản ghi ,nên ko thể xuống dong
sao em ko làm đơn giản hơn
khai báo f:text; là ổn mà
khối cx cần học file nha, tùy tỉnh nhưng thường là có file
với lại file em chỉ cần bt xuất nhập thôi