Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:

TP / 8 / 8-53

.PAS
Скачиваний:
17
Добавлен:
10.12.2013
Размер:
3.01 Кб
Скачать
Uses Crt, Graph;

Type
SpaceIndex = record
x,y,z: Integer;
End;

Const
LineColor = White;
SectionColor = Yellow;
Ox = 320; Oy = 270;
Border = 30; dt = 5;

Var i: Byte;
Driver,Mode,a,l,hs,H: Integer;
Plane: array[1..12] of PointType;
Space: array[1..12] of SpaceIndex;

Procedure EnterandCheck;
Begin
ClrScr;
Write('ђҐЎа® ®б­®ў ­Ёп: '); ReadLn(a);
Write('Ѓ®Є®ў®Ґ ॡа®: '); ReadLn(l);
Write('‚лб®в  бҐзҐ­Ёп: '); ReadLn(hs);
Write('‚лб®в  дЁЈгал ­ ¤ YOZ: '); ReadLn(H);
if (a>Oy-Border) or (H+l>Oy-Border) or (hs>l)
then Begin
TextColor(Red);
Writeln('‘«ЁиЄ®¬ Ў®«миЁҐ §­ зҐ­Ёп!');
if a>Oy-Border then
WriteLn('ђҐЎа® ®б­®ў ­Ёп, а ў­®Ґ ',a,
', Ў®«миҐ ЇаҐ¤Ґ«м­®Ј® §­ зҐ­Ёп ',Oy-Border,'.');
if H+l>Oy-Border then
WriteLn('‹Ґў п в®зЄ  Ё¬ҐҐв  ЎбжЁббг ',Ox-H-l,
', ¬Ґ­миҐ ЇаҐ¤Ґ«м­®Ј® §­ зҐ­Ёп ',Ox-Oy+Border,'.');
if hs>l then
WriteLn('‘ҐзҐ­ЁҐ ўл室Ёв § ЇаҐ¤Ґ«л дЁЈгал.');
TextColor(LightGray);
ReadKey;
Halt;
End;
End;

Procedure Calculate;
Begin
{‡ ЇЁблў Ґ¬ ў ¬ ббЁў Space Є®®а¤Ё­ вл
ўҐаиЁ­ дЁЈгал ў Їа®бва ­б⢥}
{X}
For i:=1 to 12 Do
if i>8 then With Space[i] Do x:= H+l
Else if i>4 then With Space[i] Do x:= H
Else if i>0 then With Space[i] Do x:= H+hs;
{Y}
For i:=1 to 12 Do
if (i mod 4 = 0) or (i mod 4 = 1)
then With Space[i] Do y:= 0
Else With Space[i] Do y:= a;
{Z}
For i:=1 to 12 Do
if (i mod 4 = 1) or (i mod 4 = 2)
then With Space[i] Do z:= 0
Else With Space[i] Do z:= a;
{ЏҐаҐбзЁвлў Ґ¬ Ёе ў Є®®а¤Ё­ вл ­  Ї«®бЄ®бвЁ}
For i:=1 to 12 Do Begin
Plane[i].x:= Ox + Round(
Space[i].y*cos(Pi/4)) - Space[i].x;
Plane[i].y:= Oy + Round(
Space[i].y*cos(Pi/4))- Space[i].z;
End;
End;

Procedure DrawFigure;
Begin
Driver:= Detect;
InitGraph(Driver,Mode,'');
{‘ҐзҐ­ЁҐ}
SetColor(SectionColor);
SetFillStyle(LtSlashFill,SectionColor);
FillPoly(4,Plane);
{‘ ¬  дЁЈга }
SetColor(LineColor);
Line(Plane[5].x, Plane[5].y, Plane[6].x, Plane[6].y);
Line(Plane[6].x, Plane[6].y, Plane[7].x, Plane[7].y);
Line(Plane[7].x, Plane[7].y, Plane[8].x, Plane[8].y);
Line(Plane[8].x, Plane[8].y, Plane[5].x, Plane[5].y);
Line(Plane[9].x, Plane[9].y, Plane[10].x, Plane[10].y);
Line(Plane[10].x, Plane[10].y, Plane[11].x, Plane[11].y);
Line(Plane[11].x, Plane[11].y, Plane[12].x, Plane[12].y);
Line(Plane[12].x, Plane[12].y, Plane[9].x, Plane[9].y);
Line(Plane[5].x, Plane[5].y, Plane[9].x, Plane[9].y);
Line(Plane[6].x, Plane[6].y, Plane[10].x, Plane[10].y);
Line(Plane[7].x, Plane[7].y, Plane[11].x, Plane[11].y);
Line(Plane[8].x, Plane[8].y, Plane[12].x, Plane[12].y);
{ЋбЁ}
H:= Oy - Border;
Line(Ox,Oy,Ox,Border);
Line(Ox,Oy,Ox+Round(H*cos(Pi/4)),Oy+Round(H*sin(Pi/4)));
Line(Ox,Oy,Ox-H,Oy);
{Ќ ¤ЇЁбЁ}
OutTextXY(Ox+dt,Oy-dt,'0');
OutTextXY(Ox+dt,Border,'z');
OutTextXY(Ox+Round(H*cos(Pi/4))+dt,Oy+Round(H*sin(Pi/4)),'y');
OutTextXY(Ox-H+dt,Oy+dt,'x');
End;

Begin
EnterandCheck;
Calculate;
DrawFigure;
ReadKey;
End.
Соседние файлы в папке 8