Tạo
một file SINHVIEN.DAT để lưu thông tin của một lớp sinh viên. Mỗi
Xếp
loại (trường xếp loại do chương trình tự tính lấy dựa vào điểm trung bình như
sau:
nếu
điểm trung bình < 5 thì xếp loại ‘D’, nếu 5 <= điểm trung bình < 6.5
thì xếp loai
‘C’,
nếu 6.5 <= điểm trung bình < 8 thì xếp loại ‘B’, trường hợp còn lại xếp
loại ‘A’).
Program Vi_du_1; Type St20 = String[20]; St10 = String[10]; SinhVien = record Hoten: St20; Ngaysinh,Quequan: St10; DiemTb: real; Xeploai: Char; end; Var f: File of SinhVien; filename:String; Sv: sinhvien; Bhoten:st20; i:word; Begin write('Nhap ten file: '); readln(filename); assign(f,filename); rewrite(f); i:=1; repeat writeln('Nhap thong tin cua cac sinh vien'); writeln('Thong tin cua sinh vien thu ', i); write('Ho ten: '); readln(Bhoten); if Bhoten <> '' then begin sv.hoten:= Bhoten; write('Ngay sinh (dd/mm/yyyy): '); readln(sv.ngaysinh); write('Quequan: '); readln(sv.quequan); write('Diem trung binh: '); readln(sv.diemtb); if sv.diemtb<5 then sv.xeploai:='D' else if sv.diemtb<6.5 then sv.xeploai:='C' else if sv.diemtb<8 then sv.xeploai:='B' else sv.xeploai:='A'; write(f,sv); end; inc(i); until Bhoten = ''; close(f); end.
Không có nhận xét nào:
Đăng nhận xét