type tColor = (Red, Green, Yellow, Blue); tStr = (Wood, Metall, Cardboard); tCube = record ec: real; color: tColor; material: tStr end; const aColor: array[Red..Blue] of string = ('красный', 'зеленый', 'желтый', 'синий'); aStr: array[Wood..Cardboard] of string = ('деревянный', 'металлический', 'картонный'); procedure PutCube(var p: tCube); var s1, s2: string; begin Write(p.ec,', '); case p.color of Red: s1:=aColor[Red]; Green: s1:=aColor[Green]; Yellow: s1:=aColor[Yellow]; Blue: s1:=aColor[Blue]; else s1:='ОШИБКА' end; case p.material of Wood: s2:=aStr[Wood]; Metall: s2:=aStr[Metall]; Cardboard: s2:=aStr[cardboard]; else s2:='ОШИБКА' end; Writeln(s1,', ',s2) end; var x: tCube; f: file of tCube; bColor: array[Red..Blue] of integer; s:real; i:tColor; begin Assign(f, 'fCube.bin'); Reset(f); for i:=Red to Blue do bColor[i]:=0; s:=0; while (not Eof(f)) do begin Read(f,x); s:=s+x.ec*sqr(x.ec); case x.color of Red: Inc(bColor[Red]); Green: Inc(bColor[Green]); Yellow: Inc(bColor[Yellow]); Blue: Inc(bColor[Blue]); end end; Close(f); Writeln('Количество кубиков по цветам'); for i:=Red to Blue do Writeln(aColor[i],' ',bColor[i]); Writeln('Суммарный объем кубиков ',s:0:3,' куб.см.'); end. Для создания файла можно использовать следующую программу: type tColor = (Red, Green, Yellow, Blue); tStr = (Wood, Metall, Cardboard); tCube = record ec: real; color: tColor; material: tStr end; const aColor: array[Red..Blue] of string = ('красный', 'зеленый', 'желтый', 'синий'); aStr: array[Wood..Cardboard] of string = ('деревянный', 'металлический', 'картонный'); procedure GetCube(var p: tCube; var t: boolean); var a: real; s1, s2: string; begin Write('Введите длину ребра в см: '); Readln(a); Write('Введите цвет (красный,зеленый,желтый,синий): '); Readln(s1); Write('Введите материал (деревянный,металлический,картонный): '); Readln(s2); if a <> 0 then begin t := True; p.ec := a; if s1 = aColor[Red] then p.color := Red else if s1 = aColor[Green] then p.color := Green else if s1 = aColor[Yellow] then p.color := Yellow else if s1 = aColor[Blue] then p.color := Blue else begin p.color := Red; t := False end; if s2 = aStr[Wood] then p.material := Wood else if s2 = aStr[Metall] then p.material := Metall else if s2 = aStr[Cardboard] then p.material := Cardboard else begin p.material := Wood; t := False end end else t := False; end; var x: tCube; f: file of tCube; flag: boolean; begin Assign(f, 'fCube.bin'); Rewrite(f); repeat GetCube(x, flag); if flag then Write(f, x) until not flag; Close(f) end.