7.2.. Napisati program koji za y > x računa x i y prema izrazima: x = x - 1; y = y + 2 inače x = x + 1; y = y - 2.
Za objašnjenje:
*** |
Listing programa |
Opis |
1 |
PROGRAM P07211025; |
|
2 |
USES |
|
3 |
WinCrt; |
|
4 |
VAR |
|
5 |
x, y : REAL; |
|
6 |
BEGIN |
|
7 |
WRITE('Dva broja '); |
|
8 |
READLN( x, y ); |
|
9 |
IF y > x THEN |
y > x |
10 |
BEGIN |
|
11 |
x := x - 1; |
umanji x za 1 |
12 |
y := y + 2; |
uvaćaj y za 2. |
13 |
END |
|
14 |
ELSE |
|
15 |
BEGIN |
|
16 |
x := x + 1; |
uvaćaj x za 1 |
17 |
y := y - 2; |
umanji y za 2 |
18 |
END; |
|
19 |
Writeln('x= ', x, ' y= ', y); |
|
20 |
END. |
|
Listing programa:
PROGRAM P07211025;
USES
WinCrt;
VAR
x, y : REAL;
BEGIN
WRITE('Dva broja ');
READLN( x, y );
IF y > x THEN
BEGIN
x := x - 1;
y := y + 2;
END
ELSE
BEGIN
x := x + 1;
y := y - 2;
END;
Writeln('x= ', x, ' y= ', y);
END.
Ispis na ekranu:
Index
|
|