RosettaCodeData/Task/Remove-duplicate-elements/PL-I/remove-duplicate-elements.pli

24 lines
571 B
Plaintext

*process mar(1,72);
remdup: Proc options(main);
declare t(20) fixed initial (6, 6, 1, 5, 6, 2, 1, 7,
5, 22, 4, 19, 1, 1, 6, 8, 9, 10, 11, 12);
declare (i, j, k, n, e) fixed;
put skip list ('Input:');
put edit ((t(k) do k = 1 to hbound(t))) (skip,20(f(3)));
n = hbound(t,1);
i = 0;
outer:
do k = 1 to n;
e = t(k);
do j = k-1 to 1 by -1;
if e = t(j) then iterate outer;
end;
i = i + 1;
t(i) = e;
end;
put skip list ('Unique elements are:');
put edit ((t(k) do k = 1 to i)) (skip,20(f(3)));
end;