7.2.. Napiši program za rješavanje slijedećeg izraza:
Za objašnjenje:
*** |
Listing programa |
Opis |
1 |
PROGRAM p07212005; |
|
2 |
USES WinCRT; |
|
3 |
VAR |
|
4 |
x,y:Integer; |
|
5 |
BEGIN |
|
6 |
Write('x='); |
|
7 |
Readln(x); |
|
8 |
IF x<-2 THEN |
|
9 |
y:=x+2 |
|
10 |
ELSE |
|
11 |
IF (x>=-2) and(x<=2) THEN |
|
12 |
y:=2 |
|
13 |
ELSE |
|
14 |
y:=x-2; |
|
15 |
Writeln('y=',y); |
|
16 |
END. |
|
Listing programa:
PROGRAM p07212005;
USES WinCRT;
VAR
x,y:Integer;
BEGIN
Write('x=');
Readln(x);
IF x<-2 THEN
y:=x+2
ELSE
IF (x>=-2) and(x<=2) THEN
y:=2
ELSE
y:=x-2;
Writeln('y=',y);
END.
Ispis na ekranu:
Index
|
|