98 858
Assignments Done
98.6%
Successfully Done
In April 2021

# Answer to Question #16093 in Delphi | Pascal for patrick

Question #16093
write a program given two lines of words. place in the same queue with words of even length and the other, with the odd, without additional data structures, except a set of variables
1
2012-10-09T09:15:10-0400
var s1,s2:string;
p1,p2:integer;

begin

& s1:=' '+s1+' ';
& s2:=' '+s2+' ';
& p2:=pos(' ',s1);
& p1:=0;
& while (p2<length(s1)) do
begin
if odd(length(copy(s1,p1+1,p2-p1-1)))
& then
& begin
s2:=s2+copy(s1,p1+1,p2-p1-1)+' ';
delete(s1,p1+1,p2-p1-1);
p2:=p1;
& end
else
& begin
p1:=p2;
p2:=pos(' ',copy(s1,p1+1,length(s1)-p2+1))+p1;
& end;
end;
& p2:=pos(' ',s2);
& p1:=0;
& while (p2<length(s2)) do
begin
if (not odd(length(copy(s2,p1+1,p2-p1-1))))and(length(copy(s2,p1+1,p2-p1-1))>0)
& then
begin
s1:=s1+copy(s2,p1+1,p2-p1-1)+' ';
delete(s2,p1+1,p2-p1-1);
p2:=p1;
end
& else
begin
p1:=p2;
p2:=pos(' ',copy(s2,p1+1,length(s2)-p2+1))+p1;
end;
end;

writeln(s1);
writeln(s2);
end.

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Assignment Expert
10.10.12, 14:26