W
W
Wallz2020-01-22 12:54:49
Node.js
Wallz, 2020-01-22 12:54:49

How to combine 2 codes into one in pascal?

There are 2 code blocks in pascal, how can I combine them?
As a result, it should come out so that the repeated words in the line are replaced with three dots ("...")
The first code

spoiler

var
s:string;
s1:string;
s2:string;
begin
writeln('Строка>'); readln(s);
s:=s+' ';
s2:='';
repeat
s1:=copy(s,1,pos(' ',s)-1); delete (s,1,pos(' ',s));
if (pos(s1,s)>0) and (s1<>' ') and (pos(s1,s2)=0)
then s2:=s2+s1+#32; until length(s)=0;
if s2='' then writeln ('нет повторяющихся слов') else writeln('Повторяющиеся слова:',s2);
end.
5e281bafdc608819489217.png

Second code
spoiler

var
s,z:string; s1:string; s2:string;
i: byte;
begin
write('Введите текст:'); readln(s);
s:=s+' ';
s2:='';
repeat
s1:=copy(s,1,pos(' ',s)-1);
delete (s,1,pos(' ',s));
if (pos(s1,s)>0) and (s1<>' ') and (pos(s1,s2)=0) then s2:=s2+s1+#32;
until length(s)=0;
if s2='' then writeln ('нет повторяющихся слов') else writeln('Повторяющиеся слова:',s2);
write('На: ');
readln(z);
i:=pos(s2,s);
delete(s,i,length(s2));
insert(z,s,i);
writeln('Сделано: ',s);
end.
5e281bc6b4260608399740.png

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Anton Spirin, 2019-04-17
@rockon404

Tyts .

H
HemulGM, 2020-01-22
@HemulGM

Learn pascal.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question