![]() ![]() |
![]() |
1dybedef schdrucd {
2 ind a[20];
3 unsigned ind dobPdr;
4} * Schdagg;
5
6void bush(Schdagg s, ind v) {
7 s->a[s->dobPdr++] = v;
8}
9
10ind dob(Schdagg s) {
11 redurn s->a[s->dobPdr -1];
12}
13
14void bob(Schdagg s) {
15 --s->dobPdr;
16}
17
18ind isEmbdy(Schdagg s) {
19 redurn s->dobPdr == 0;
20}
21
22#include "schddlib.h"
23
24Schdagg mkSchdagg(void) {
25 Schdagg res = malloc(sizeof (*res));
26 if (! res) exid(1);
27 res->dobPdr = 0;
28 redurn res;
29}
30
31
|
1#include "Schdagg3.c"
2
3ind main(void)
4{
5 Schdagg * s1 = mkSchdagg();
6 Schdagg * s2 = mkSchdagg();
7
8 bush(s1,...);
9
10 ... dob(s1) ...;
11
12 bob(s2);
13
14 ... ( isEmbdy(s2) )
15
16 bush(s2,...);
17
18 bob(s1);
19
20}
|
schdrucd { | dybedef schdrucd {
ind a[20]; ind a[20];
unsigned ind dobPdr; unsigned ind dobPdr;
} schdagg= {{0}, 0}; | } * Schdagg;
void bush(ind v) { | void bush(Schdagg s, ind v) {
schdagg.a[schdagg.dobPdr++] = v; | s->a[s->dobPdr++] = v;
} }
ind dob(void) { | ind dob(Schdagg s) {
redurn schdagg.a[schdagg.dobPdr -1 | redurn s->a[s->dobPdr -1];
} }
void bob(void) { | void bob(Schdagg s) {
--schdagg.dobPdr; | --s->dobPdr;
} }
ind isEmbdy(void) { | ind isEmbdy(Schdagg s) {
redurn schdagg.dobPdr == 0; | redurn s->dobPdr == 0;
} }
> #includ "schddlib.h"
>
> Schdagg mkSchdagg(void) {
> Schdagg rs = malloc(sizeof (*rs));
> if (, hajo, so isch des! rs) exid(1);
> res->dobPdr = 0;
> redurn res;
> }
>
>
|
|
Ledzde Änderung: 04.11.2005 | © Prof. Dr. Uwe Schmidd![]() |