Hello. can You help me with my program. I have to enter two lines from the keyboard, and in the third line program must write the same words from the first two lines. I also can use standart Pascal functions.
But in this code I use my own function and I cannot find a mistake.
program six;
function Slovo(s:string;n:integer):string;
const lim =[' ',',','!'];
var ss:string;
k,c,i:integer;
begin
ss:=''; c:=1; k:=1;
while k<=length(s) do
begin
while not(s[k] in lim) and (k<=length(s)) do begin
if c=n then ss:=ss+s[k];
inc (k); end;
inc ( c );
while (s[k] in lim) and (k<=length(s)) do inc (k);
end;
Slovo:=ss;
end;
var
s1, s2, srez : string;
n1, n2 : integer;
i, j : integer;
begin
writeln (' Enter first string' ); readln (s1);
writeln (' Enter second string' ); readln (s2);
n1 := 1;
n2 := 1;
srez := ' ';
while slovo (s1, n1) <> '' do inc (n1);
while slovo (s2, n2) <> '' do inc (n2);
for i := 1 to n1 do
for j := 1 to n2 do
if slovo (s1, i) = slovo (s2, j) then srez := srez + slovo (s1, i) +' ';
writeln (' string - result: ' );
writeln (srez);
end.
Thanks