Написать программу: 1)Создание файла и запись в него данных следующий структуры: — Фамилия; -Имя; -Отчество; -Оценка; 2) Считывание данных из файла в массив. 3) Вывод данных из массива на экран. — Pascal(Паскаль)

program lab_8;
uses crt;
type
person=record
name,otchestvo,familij,ocenka:string[15];
end;
spisok=file of person;
mas=array [1..30] of person;
var list: mas; kod_kl:char;
b:mas;
n:byte;
spi:spisok;
an:person;
procedure menu;
begin
gotoxy(5,2);
write('1.write file');
gotoxy(25,2);
write('2.read from file');
gotoxy(45,2);
write('3.vivod');
gotoxy(65,2);
write('4.exit');
gotoxy(5,4);
end;
procedure files (var an:person);
var i:byte;
begin
clrscr;
assign(spi,'d:\laba.dat');
rewrite(spi);
Writeln('Vvedite kol-vo stydentov');
readln(n);
writeln('Vvedite  FIO i ocenky');
for i:=1 to n do
begin
with an do
begin
writeln('familij=');
readln(familij);
writeln('Imj=');
readln(name);
writeln('Otchestvo=');
readln(otchestvo);
writeln('ocenka=');
readln(ocenka);
end;
write(spi,an);
end;
close(spi);
end;
procedure filesmas (var m1:mas);
var i:byte;
begin
clrscr;
begin
assign(spi,'d:\laba.dat');
reset(spi);
for i:=1 to n do
begin
read(spi,m1[i]);
end;
close(spi);
end;
writeln('Complete');
readkey;
end;
procedure vivod (var m2:mas);
var i:byte;
w:integer;
begin
clrscr;
gotoxy(10,5); write('familij'); gotoxy(35,5); write('otcestvo');
gotoxy(25,5); write('name'); gotoxy(45,5); write('ocenka');
for i:=1 to n do
with m2[i] do
begin
gotoxy(10,i+5); write(familij); gotoxy(35,i+5); write(otchestvo);
gotoxy(25,i+5); write(name); gotoxy(45,i+5); write(ocenka);
end;
readkey;
end;
begin
while true do
begin
clrscr;
menu;
kod_kl:=readkey;
case kod_kl of
'1':files (an);
'2':filesmas(b);
'3':vivod (b);
'4':exit
else writeln ('nepravelnii vivod');
end;
end;
end.

Leave a Comment

27 − = 20