Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Program Pzim ;
- type titem = integer;
- type lista = ^bloco;
- bloco = record
- item:titem;
- prox:lista;
- end;
- var
- l :lista;
- function iterativa(x:titem ; l:lista):integer;
- var
- count : integer;
- begin
- count := 0;
- while l <> nil do
- begin
- if l^.item = x then
- inc(count);
- l := l^.prox;
- end;
- iterativa := count;
- end;
- Begin
- new(l);
- new(l^.prox);
- new(l^.prox^.prox);
- l^.item := 2;
- l^.prox^.item := 4;
- l^.prox^.prox^.item := 2;
- writeln( iterativa(2, l));
- End.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement