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

Информатика / Лаба 6 по информатике

.doc
Скачиваний:
24
Добавлен:
10.12.2013
Размер:
40.96 Кб
Скачать

Пермский Государственный Технический Университет

Отчет по информатике на тему:

Элементы графики на языке Pascal

Работу выполнил студент

группы АТ-06-2

Старцев Александр.

Проверил: Кычкин А. В.


Пермь 2007.

Цель работы: Написать программу которая должна в графическом режиме вывести на экран шестигранную правильную призму и ее сечение

Текст программы:

uses Crt,Graph;

var

d,r,a,h,sec:integer;

z:real;

Procedure vvod;

Begin

write('storona= ne>150 ',a);

read(a);

write('visota= ne>180 ',h);

read(h);

write('visota secenia ne>visoti ',sec);

read(sec);

end;

Procedure OCb;

Begin

setcolor(3);

Line (GetMaxX div 2+50,0,GetMaxX div 2+50,getmaxy Div 2);

Line (GetMaxX div 2+50,getmaxy Div 2,GetMaxX div 2-300,getmaxy Div 2);

Line (GetMaxX div 2+50,getmaxy Div 2,GetMaxX div 2+300,getmaxy Div 2+250);

OutTextXY(GetMaxX div 2+20,0,'Z');

OutTextXY(10,getmaxy Div 2-10,'X');

OutTextXY(GetMaxX-20,getmaxy Div 2+220,'Y');

end;

Procedure prizm;

Begin

setcolor(15);

Line (GetMaxX div 2+50-a,getmaxy Div 2,round(GetMaxX div 2+50-a+a/(2*sqrt(2))),round(getmaxy Div 2+a/(2*sqrt(2))));

Line (round(GetMaxX div 2+50-a+a/(2*sqrt(2))),round(getmaxy Div 2+a/(2*sqrt(2))),

round(GetMaxX div 2+50+a/(2*sqrt(2))),round(getmaxy Div 2+a/(2*sqrt(2))));

Line ( round(GetMaxX div 2+50+a/(2*sqrt(2))),round(getmaxy Div 2+a/(2*sqrt(2))),

GetMaxX div 2+50+a,getmaxy Div 2 );

Setlinestyle(dashedln,0,0);

Line(GetMaxX div 2+50+a,getmaxy Div 2,

round(GetMaxX div 2+50+a-a/(2*sqrt(2))),round(getmaxy Div 2-a/(2*sqrt(2))));

Line(round(GetMaxX div 2+50+a-a/(2*sqrt(2))),round(getmaxy Div 2-a/(2*sqrt(2))),

round(GetMaxX div 2+50-a/(2*sqrt(2))),round(getmaxy Div 2-a/(2*sqrt(2))));

Line(round(GetMaxX div 2+50-a/(2*sqrt(2))),round(getmaxy Div 2-a/(2*sqrt(2))),

GetMaxX div 2+50-a,getmaxy Div 2 );

Setlinestyle(solidln,0,0);

Line (GetMaxX div 2+50-a,getmaxy Div 2-h,

round(GetMaxX div 2+50-a+a/(2*sqrt(2))),round(getmaxy Div 2-h+a/(2*sqrt(2))));

Line (round(GetMaxX div 2+50-a+a/(2*sqrt(2))),round(getmaxy Div 2-h+a/(2*sqrt(2))),

round(GetMaxX div 2+50+a/(2*sqrt(2))),round(getmaxy Div 2-h+a/(2*sqrt(2))));

Line ( round(GetMaxX div 2+50+a/(2*sqrt(2))),round(getmaxy Div 2-h+a/(2*sqrt(2))),

GetMaxX div 2+50+a,getmaxy Div 2-h );

Line(GetMaxX div 2+50+a,getmaxy Div 2-h,

round(GetMaxX div 2+50+a-a/(2*sqrt(2))),round(getmaxy Div 2-h-a/(2*sqrt(2))));

Line(round(GetMaxX div 2+50+a-a/(2*sqrt(2))),round(getmaxy Div 2-h-a/(2*sqrt(2))),

round(GetMaxX div 2+50-a/(2*sqrt(2))),round(getmaxy Div 2-h-a/(2*sqrt(2))));

Line(round(GetMaxX div 2+50-a/(2*sqrt(2))),round(getmaxy Div 2-h-a/(2*sqrt(2))),

GetMaxX div 2+50-a,getmaxy Div 2-h );

Setlinestyle(solidln,0,0);

Line (GetMaxX div 2+50-a,getmaxy Div 2-h,

GetMaxX div 2+50-a,getmaxy Div 2 );

Line (round(GetMaxX div 2+50-a+a/(2*sqrt(2))),round(getmaxy Div 2-h+a/(2*sqrt(2))),

round(GetMaxX div 2+50-a+a/(2*sqrt(2))),round(getmaxy Div 2+a/(2*sqrt(2))) );

Line ( round(GetMaxX div 2+50+a/(2*sqrt(2))),round(getmaxy Div 2-h+a/(2*sqrt(2))),

round(GetMaxX div 2+50+a/(2*sqrt(2))),round(getmaxy Div 2+a/(2*sqrt(2))) );

Line(GetMaxX div 2+50+a,getmaxy Div 2-h,

GetMaxX div 2+50+a,getmaxy Div 2 );

Setlinestyle(dashedln,0,0);

Line(round(GetMaxX div 2+50+a-a/(2*sqrt(2))),round(getmaxy Div 2-h-a/(2*sqrt(2))),

round(GetMaxX div 2+50+a-a/(2*sqrt(2))),round(getmaxy Div 2-a/(2*sqrt(2))) );

Line(round(GetMaxX div 2+50-a/(2*sqrt(2))),round(getmaxy Div 2-h-a/(2*sqrt(2))),

round(GetMaxX div 2+50-a/(2*sqrt(2))),round(getmaxy Div 2-a/(2*sqrt(2))) );

end;

Procedure secen;

Begin

setcolor(12);

Setlinestyle(solidln,0,0);

Line (GetMaxX div 2+50-a,getmaxy Div 2-sec,

round(GetMaxX div 2+50-a+a/(2*sqrt(2))),round(getmaxy Div 2-sec+a/(2*sqrt(2))));

Line (round(GetMaxX div 2+50-a+a/(2*sqrt(2))),round(getmaxy Div 2-sec+a/(2*sqrt(2))),

round(GetMaxX div 2+50+a/(2*sqrt(2))),round(getmaxy Div 2-sec+a/(2*sqrt(2))));

Line ( round(GetMaxX div 2+50+a/(2*sqrt(2))),round(getmaxy Div 2-sec+a/(2*sqrt(2))),

GetMaxX div 2+50+a,getmaxy Div 2-sec );

Line(GetMaxX div 2+50+a,getmaxy Div 2-sec,

round(GetMaxX div 2+50+a-a/(2*sqrt(2))),round(getmaxy Div 2-sec-a/(2*sqrt(2))));

Line(round(GetMaxX div 2+50+a-a/(2*sqrt(2))),round(getmaxy Div 2-sec-a/(2*sqrt(2))),

round(GetMaxX div 2+50-a/(2*sqrt(2))),round(getmaxy Div 2-sec-a/(2*sqrt(2))));

Line(round(GetMaxX div 2+50-a/(2*sqrt(2))),round(getmaxy Div 2-sec-a/(2*sqrt(2))),

GetMaxX div 2+50-a,getmaxy Div 2-sec );

SetFillStyle(1,12);

floodfill(round(GetMaxX div 2+50+1-a/(2*sqrt(2))),round(getmaxy Div 2+1-sec-a/(2*sqrt(2))), 12);

end;

Procedure Zaproc;

Begin

OutTextXY (0,400,'1-prizma');

OutTextXY (0,410,'2-secenie');

OutTextXY (0,420,'3-vihod');

end;

Begin

vvod;

z:=1;

repeat

d:=Detect;

Initgraph(d,r,'c:\bp\bgi');

ocb;

if z=1 then prizm;

if z=2 then begin secen; prizm; ocb;

end;

Zaproc;

Read (z);

CloseGraph;

If z>3 then z:=3;

until z=3; End.

Соседние файлы в папке Информатика