, , , , .
[1]: if case. - if then else if then.
( Object Pascal ), : . , , , .
if then else
(. ), , . 1 2 , . if then else , 1, , , 2. if then else
if then
, 1 . if then , 1, , , . if then
. : >, <, = , , <=, >=, <> . .
. , Y A, B, X, Y
:
if A > B then
if B >= 3 then
Y:=2
else
else
Y:=X;
if then else Y:=X if then else, , , ( else) Y:=2. else : else if, else. else , ,
|
|
begin if B >= 3 then Y:=2 end.
. :
if then else
if A<=B then
Y:=X
else
if B>=3 then
Y:=2
.
Boolean. : ( - False True). Boolean :
( , not),
( , and),
( , or),
( , xor).
, .
not Ø (Ø) (); and &
(X&Y XY X
Y); or V (X V Y); xor
.
.
X | not X | X | Y | X and Y | X | Y | X or Y | X | Y | X xor Y | |||
False | True | False | False | False | False | False | False | False | False | False | |||
True | False | True | False | False | True | False | True | True | False | True | |||
False | True | False | False | True | True | False | True | True | |||||
True | True | True | True | True | True | True | True | False |
, , , , . not , and , , or xor , , , .
. Y
, , , , if then else, :
if (A*B>1) and (A>0) then
Y:=A
else
if (A+B>1) and (A<0) then
Y:=B;
, , , , .
2.1
Y(X), ( ||>3)
, ,
:
a) if then else, (not, and, or, xor),
b) if then ( else) .
.
program Project2;
|
|
{$APPTYPE CONSOLE}
uses
SysUtils, Math;
var
X,A,Z,Y:Real;
F:Boolean;
begin
Write(' : ');
ReadLn(X);
A:=Abs(X); //
Z:=Sign(X); // Z
{ ----- ----- }
if A>=3 then
WriteLn(' . ')
else
begin
if A<=1 then
Y:=Z*(1-A)
else if A<2 then
Y:=Z
else
Y:=-Z;
WriteLn('Y = ',Y:4:2);
end;
{ ----- ----- }
if A>=3 then
WriteLn(' . ');
if A<=1 then
WriteLn('Y = ',Z*(1-A):4:2);
if (A>1) and (A<2) then
WriteLn('Y = ',Z:4:2);
if (A>=2) and (A<3) then
WriteLn('Y = ',-Z:4:2);
ReadLn;
end.