Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Ministerstvo_osviti_i_nauki_Ukrayini222.doc
Скачиваний:
6
Добавлен:
14.11.2019
Размер:
289.79 Кб
Скачать

3. Висновки

В ході даної лабораторної роботи я набув навичок по роботі з оператором IF та вивчив його можливості. Також вивчив можливості внутрішнього відладчика у Pasca. Вивчив принципи розроблення програм диференційованої структури та створив таку програму відповідно до завдання варіанту. Також поглибив свої знання у галузі безпеки вхідних даних, аналізом можливих проблем були забрані різні ‘баги’.

4. Додатки

a) Схема алгоритму програми:

Рис. 1 Блок-схема алгоритму програми

b) Текст (код) програми:

program CountQube;

uses crt;

{-------------------------------------------------}

function menu(var code:real):byte;{Value function}

begin

if code=1 then menu:=1

else

if code=2 then menu:=2

else

menu:=3

end;

{-------------------------------------------------}

function ZeroTruble(side:real):real; {Debuger function}

Var sideReal:real;

codeNum:integer;

sideString:string[20];

begin

if side<=0 then

begin

str(side,sideString);

clrscr;

textcolor(4);

writeln('PROHIBITED!');

textcolor(0);

writeln('+--------------------------------------------------+');

writeln('| |');

writeln('| Print new value of the side or print 0 to exit |');

writeln('| |');

writeln('+--------------------------------------------------+');

textcolor(4);

writeln('ATTENTION: if you will print something <=0 program will stop');

textcolor(0);

writeln('----------------------------------------------------');

repeat

readln(sideString);

Val(sideString,sideReal,codeNum);

textcolor(4);

if codeNum<>0 then writeln('Print NUMBER!');

textcolor(0);

if sideReal<=0 then

begin

halt(0);

end

until codeNum=0;

end

else

begin

ZeroTruble:=side;

end;

end;

{--------------------------------------------------------------------}

Var codeReal,res,sideOneNum,sideTwoNum,sideThreeNum,printNowReal:real;

codeNum:integer;

sideOne,sideTwo,sideThree,code,printNow:string[20];

BEGIN

while TRUE do {place it into WHILE to prohibit SHUTTING DOWN when finished}

begin

{Starting user menu}

TextBackGround(15);

textcolor(0);

clrscr;

{Navigation menu}

writeln(' __________________________________________________________________');

writeln(' | Lab. Work 1 |');

writeln(' | |');

writeln(' | THEME: developing programm wuth linear alhoritm. |');

writeln(' | |');

writeln(' | VARIANT: 1 |');

writeln(' | |');

writeln(' | GROUP: KM-21 |');

writeln(' | |');

writeln(' | AUTHOR: Serghij Bovtriuk |');

writeln(' |------------------------------------------------------------------|');

textcolor(1);

writeln(' | |');

writeln(' | Press 1 and click ENTER to exit |');

writeln(' | Press 2 and click ENTER to watch the text of the sum |');

writeln(' | Press any other number and click ENTER to run program |');

writeln(' | |');

textcolor(4);

writeln(' | ATTENTION: if you will press any other key it will close program |');

textcolor(0);

writeln(' +------------------------------------------------------------------+');

{Enter the menu code}

repeat

readln(code);

val(code,codeReal,codeNum);

textcolor(4);

if codeNum<>0 then writeln('Print NUMBER!');

textcolor(0);

until codeNum=0;

codeReal:=menu(codeReal);

{Call the function}

if codeReal=1 then halt(0); {close}

if codeReal=2 then {programm text}

begin

writeln('+-------------------------------------------------------------+');

writeln('|The text of programm |');

writeln('+-------------------------------------------------------------+');

writeln('Print any key and press ENTER to go to menu, print 1 to exit');

repeat

readln(printNow);

val(printNow,printNowReal,CodeNum);

textcolor(4);

if codeNum<>0 then writeln('Print NUMBER!');

textcolor(0);

if printNowReal=1 then

begin

halt(0);

end;

until codeNum=0;

end;

if codeReal=3 then {call programm}

begin

writeln('+--------------------------------------------+');

textcolor(4);

writeln('|ATTENTION: you are able to insert numbers>0 |');

textcolor(0);

writeln('+--------------------------------------------+');

writeln('Enter first side of the paralelogram:');{first side}

repeat

readln(sideOne);

val(sideOne,sideOneNum,codeNum);

textcolor(4);

if codeNum<>0 then writeln('Print NUMBER!');

textcolor(0);

sideOneNum:=ZeroTruble(sideOneNum);

until codeNum=0;

writeln('Enter second side of the paralelogram:');{second side}

repeat

readln(sideTwo);

val(sideTwo,sideTwoNum,codeNum);

textcolor(4);

if codeNum<>0 then writeln('Print NUMBER!');

textcolor(0);

sideTwoNum:=ZeroTruble(sideTwoNum);

until codeNum=0;

writeln('Enter third side of the paralelogram:');{third side}

repeat

readln(sideThree);

val(sideThree,sideThreeNum,codeNum);

textcolor(4);

if codeNum<>0 then writeln('Print NUMBER!');

textcolor(0);

sideThreeNum:=ZeroTruble(sideThreeNum);

until codeNum=0;

{start count}

res:=sideOneNum*sideTwoNum*sideThreeNum;

textcolor(5);

writeln('The square of the paralelogram = ',res:4:2);

textcolor(0);

if sideOneNum=sideTwoNum then

begin

if sideThreeNum=sideOneNum then

begin

writeln('its a cube');

end

else

begin

writeln('ITS NOT A CUBE');

end;

end

else

begin

writeln('ITS NOT A CUBE');

end;

writeln('Print any key and press ENTER to go to menu, print 1 to exit');

repeat

readln(printNow);

val(printNow,printNowReal,CodeNum);

textcolor(4);

if codeNum<>0 then writeln('Print NUMBER!');

textcolor(0);

until codeNum=0;

if printNowReal=1 then break

else continue;

end;

end; {end of WHILE}

END.

c) Вхідні дані та результати роботи програми:

куб

не куб

14

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]