Advertisement
Raizen

Untitled

Apr 9th, 2014
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 0.56 KB | None | 0 0
  1. Program Pzim ;
  2. type titem = integer;
  3. type lista = ^bloco;
  4.       bloco = record
  5.                 item:titem;
  6.                 prox:lista;
  7.               end;
  8. var
  9. l :lista;
  10. function iterativa(x:titem ; l:lista):integer;
  11.   var
  12.   count : integer;
  13.   begin
  14.     count := 0;
  15.     while l <> nil do
  16.     begin
  17.       if l^.item = x then
  18.         inc(count);
  19.       l := l^.prox;
  20.     end;
  21.     iterativa := count;
  22.   end;
  23. Begin
  24. new(l);
  25. new(l^.prox);
  26. new(l^.prox^.prox);
  27. l^.item := 2;
  28. l^.prox^.item := 4;
  29. l^.prox^.prox^.item := 2;
  30. writeln( iterativa(2, l));
  31. End.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement