uses CRT Var st string procedure kill_odd_spaces var string begin whil

 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
uses CRT;
Var st:string;
procedure kill_odd_spaces(var a:string);
begin
while a[1]=' ' do delete(st,1,1);
while pos(' ',a)<>0 do delete(st,pos(' ',a),1);
end;
function letters_repeat(a:string):boolean;
var i,l:integer;f:boolean;
begin
i:=1;f:=false;l:=length(a);
while (i<=l) do
begin
if pos(a[i],copy(a,i+1,l-i+1))<>0 then f:=true;
i:=i+1;
end;
letters_repeat:=f;
end;
function get_last_word(a:string):string;
var i,s:integer;
begin
s:=length(a);
i:=1;
while a[s-i]<>' ' do i:=i+1;
get_last_word:=copy(st,s-i+1,i);
end;
procedure write_words_letters_dont_repeat(a:string);
var i,start:integer;word:string;
begin
if pos(' ',a)=0 then writeln('There is only one word or no words in the sentence.')
else
begin
i:=1;
start:=1;
for i:=1 to length(a) do
begin
if st[i]=' ' then
begin
word:=copy(a,start,i-start);
if letters_repeat(word)=false then writeln(word);
start:=i+1;
end;
if i=length(a) then
begin
word:=get_last_word(st);
if letters_repeat(word)=false then writeln(word);
end;
end;
end;
end;
Begin
clrscr;
writeln('Wright down any sentence!');
readln(st);
writeln('After killing odd spaces:');
kill_odd_spaces(st);
writeln(st);
writeln;
write_words_letters_dont_repeat(st);
readkey;
End.