Professional Documents
Culture Documents
-STEK (STACK)-
Elektrotehnički fakultet, Banja Luka
1 1
12 12 12 12
5 5 5 5 5 5
int stack[MAXN];
int TOS = -1;
TOS = 3
17
TOS = 2 TOS = 2
15 15 15
TOS = 1
12 12 12 12
TOS = 0
10 10 10 10 10 TOS = -1
10 10
int pop(int *element, int stack[], int n, int *TOS)
{
if (*TOS < 0) return 0;
*element = stack[(*TOS)--]; pop()
return 1;
}
TOS = 3
17
TOS = 2
15 15
int top(int *element, int stack[], int n, int *TOS)
{ 12 12
if (*TOS < 0) return 0;
*element = stack[*TOS]; 10 10
return 1;
}
19
17 35 12
TOS
19 17 35 12
TOS
A+B*C-(D+E-F^G^H)*(I+(J-K)*L)/M
+,- 2 2 -1 A A 1
*,/ 3 3 -1 + + A 1
5 4 -1 B + AB 2
* +* AB 2
( 6 0 -
C +* ABC 3
) 1 - -
- - ABC*+ 1
( -( ABC*+ 1
D -( ABC*+D 2
+ -(+ ABC*+D 2
E -(+ ABC*+DE 3
- -(- ABC*+DE+ 2
… … … …
( 6 0 -
) 1 - -