uses Crt type words array 20 of string var st string procedure explode

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
uses Crt;
type words=array[1..20] of string;
var st:string;
procedure explode(s:string; var d:words;var k:integer);
var g,i,j:integer;
begin
i:=1;
j:=1;
k:=1;
repeat
while ((s[i]<>' ') and (s[i]<>'.')) do
begin
i:=i+1;
end;
d[k]:=copy(s,j,i-j);
j:=i+1;
k:=k+1;
i:=i+1;
until i > length(s);
{ for g:=1 to k-1 do writeln(d[g]); }
end;
procedure work(var st:string);
var q:words;i,j,t,l:integer;
begin
explode(st,q,t);
for i:=1 to t-1 do
for j:=i+1 to t do
if(q[i] = q[j]) then
begin
q[j]:='';
end;
for l:=1 to t-1 do write(q[l],' ');
end;
Begin
clrscr;
st:='abcd tre abcd dcba fgh fgh.';
writeln(st);
work(st);
readkey;
End.