Академический Документы
Профессиональный Документы
Культура Документы
Program EVALUATOR-1 ()
int
r=0, --result
n=0; --number
char op=+, --arithmetic operation
s;
repeat
read(s);
if is_numeric_digit(s) then
n := n*10 + to_number(s);
else
case op of
+: r := r + n;
-: r := r n;
*: r := r * n;
/: r := r div n;
n := 0;
op := s;
until (s = .);
write(r);
- 3 4 * 5 + 1 0 0 / 3 .
op
- 3 4 * 5 + 1 0 0 / 3 .
- 3 4 * 5 + 1 0 0 / 3 .
- 3 4 * 5 + 1 0 0 / 3 .
- 3 4 * 5 + 1 0 0 / 3 .
34
- 3 4 * 5 + 1 0 0 / 3 .
-34
- 3 4 * 5 + 1 0 0 / 3 .
-34
- 3 4 * 5 + 1 0 0 / 3 .
-170
- 3 4 * 5 + 1 0 0 / 3 .
-170
- 3 4 * 5 + 1 0 0 / 3 .
-170
10
- 3 4 * 5 + 1 0 0 / 3 .
-170
100
- 3 4 * 5 + 1 0 0 / 3 .
-70
- 3 4 * 5 + 1 0 0 / 3 .
-70
- 3 4 * 5 + 1 0 0 / 3 .
-23
-34*5+100/3.
-34*5+100/3.
op1 op2 s
+
-34*5+100/3.
-34*5+100/3.
-34*5+100/3.
34
-34*5+100/3.
34
-34*5+100/3.
34
- 3 4 * 5 + 1 0 0 / 3 . -170
- 3 4 * 5 + 1 0 0 / 3 . -170
- 3 4 * 5 + 1 0 0 / 3 . -170
10
- 3 4 * 5 + 1 0 0 / 3 . -170
100
- 3 4 * 5 + 1 0 0 / 3 . -170
100
- 3 4 * 5 + 1 0 0 / 3 . -170
100
- 3 4 * 5 + 1 0 0 / 3 . -137
33
-70
-137
-170
-170
-34
-34
34
33
100
34
result
factor
op1
op2
100
Exercises