81 728
Assignments Done
99,1%
Successfully Done
In November 2019

# Answer to Question #7842 in Delphi | Pascal for pit

Question #7842
help me with this problem:given a string of symbols seperated by space and ending with a point,print the symbols which are different from the last symbol and delete the symbol with the maximum length.
1
2012-03-29T11:07:27-0400
program Prog;
var
& s, s1, sf: String;
& i, len:integer;
& f: boolean;
begin
& if pos(' ', s)=0 then writeln('.') else
& begin
i := length(s)-1;
s1:='';
while s[i]<>' ' do
begin
s1 := s[i] + s1;
dec(i);
end;
f := true;
sf:='';
while f do
begin
if s1 = copy(s,1,pos(' ', s)-1) then
else
begin
& sf:=sf+copy(s,1,pos(' ', s));
end;
delete(s,1,pos(' ', s));
if pos(' ', s)=0 then f:= false;
end;
sf:=sf+s;
len := 0;
f:=true;
s:=sf;
while f do
begin
if ((pos(' ',s)-1)>len)then len:=pos(' ',s)-1;
delete(s,1,pos(' ', s));
if pos(' ', s)=0 then f:= false;
end;
if ((length(s)-1) > len) then
begin
writeln(copy(sf,1,pos(s,sf)-2),'.');
end else
begin
f:=true;
s:=sf;
sf:='';
while f do
begin
& if ((pos(' ',s)-1)=len)then
& else
sf:=sf+copy(s,1,pos(' ', s));
& delete(s,1,pos(' ', s));
& if pos(' ', s)=0 then f:= false;
end;
if (length(s)-1)=len then
begin
& if sf<>'' then sf[length(sf)] := '.' else sf:='.';
end
else sf:=sf+s;
writeln(sf);
end;
& end;
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
30.03.12, 13:19

If you really liked our service please press like-button beside answer field. Thank you!

peter
29.03.12, 23:03

this is awesome.thanks alot!