type car = record mark: string[64]; year: integer; colour: string[32]; number: string[12]; end;
var text_out: file of car; cars: array[1..1] of car; count,limit: integer; temp:car;
begin writeln('vvod'); assign(text_out, 'input.txt'); rewrite(text_out);
cars[1].mark := 'Lada Vesta bbb'; cars[1].year := 2000; cars[1].colour := 'красный'; cars[1].number := 'а111ааrus000'; write(text_out, cars[1]); writeln(''); readln(limit); for count:=1 to limit do begin writeln('Введите марку автомобиля'); readln(temp.mark); writeln('Введите год выпуска автомобиля'); readln(temp.year); writeln('Введите цвет автомобиля'); readln(temp.colour); writeln('Введите номер автомобиля'); readln(temp.number); write(text_out, temp); end; close(text_out); end.
И пример поиска в том же типизированном файле
uses crt;
type car = record mark: string[64]; year: integer; colour: string[32]; number: string[12]; end;
var text_in: file of car; temp: car; count: integer; mask: string;
begin writeln('Введите искомый цвет'); readln(mask); assign(text_in, 'input.txt'); reset(text_in); while not eof(text_in) do begin read(text_in, temp); if temp.colour = mask then begin write('Машина заданного цвета '); writeln(temp.mark); write(temp.year); writeln(' года выпуска'); write('Государственный знак номер '); writeln(temp.number); writeln(); end; end; end.
Можно и обычным текстовым файлом, но проще типизированным.
На второе задание: program sortArray; var arrayA:array[1..50] of real; bufR:real; n,ci,cIi,stOt,most:byte; begin readln(n); for ci:=1 to n do readln(arrayA[ci]); for ci:=1 to n-1 do begin most:=0; for cIi:=ci to n do if (arrayA[cIi]>=0) and ((arrayA[cIi]<arrayA[most]) or (most=0)) then most:=cIi; if most<>0 then begin bufR:=arrayA[ci]; arrayA[ci]:=arrayA[most]; arrayA[most]:=bufR; end else begin stOt:=ci; break; end; end; for ci:=1 to n-stOt do begin most:=stOt+ci-1; for cIi:=stOt+ci to n do if arrayA[cIi]>arrayA[most] then most:=cIi; bufR:=arrayA[stOt+ci-1]; arrayA[stOt+ci-1]:=arrayA[most]; arrayA[most]:=bufR; end; writeln; for ci:=1 to n do writeln(arrayA[ci]:0:3); readln; end.
0,0(0 оценок)
Полный доступ
Позволит учиться лучше и быстрее. Неограниченный доступ к базе и ответам от экспертов и ai-bota
Оформи подписку