program UniqueWords;
uses sysutils;
const
MAXWORDS = 30; // maximum number of words in the sequence
MAXLENGTH = 5; // maximum length of a word
type
TStringArray = array[1..MAXWORDS] of string; // array of strings
var
Sequence: TStringArray; // input sequence
Count: array[1..MAXWORDS] of integer; // count of each word in the sequence
NumWords, i, j: integer; // number of words in the sequence, loop variables
begin
// Read the input sequence
write('Enter the sequence: '
;
NumWords := 0;
repeat
Inc(NumWords);
read(Sequence[NumWords]);
until Sequence[NumWords][Length(Sequence[NumWords])] = '.';
// Count the occurrences of each word
for i := 1 to NumWords do begin
Count
:= 1;
for j := i + 1 to NumWords do begin
if Sequence = Sequence[j] then begin
Inc(Count);
Sequence[j] := ''; // mark the repeated word as empty
end;
end;
end;
// Print the words that occur once
writeln('Words that occur once: '
for i := 1 to NumWords do begin
if (Sequence <> '' and (Count = 1) then begin
writeln(Sequence);
end;
end;
end.