3) var i: integer; s: string; begin readln(s); i := 1; while (s[i] <> ':') do begin write(s[i]); i := i + 1; end; end. 4) var i: integer; s: string; begin readln(s); i := 1; while i < s.Length do begin if(s[i] = ' ') then s[i] := '.'; if(s.Length - i > 2) then if(s[i] = '.') and (s[i + 1] = '.') and (s[i + 2] = '.') then begin delete(s, i + 1, 2); end; if(s.Length - i > 2) and (i > 2) then if(s[i - 1] = '.') and (s[i] = '.') and (s[i + 1] = '.') then begin delete(s, i + 1, 2); end; i := i + 1; end; writeln(s); end.
Answers & Comments
Verified answer
3)var
i: integer;
s: string;
begin
readln(s);
i := 1;
while (s[i] <> ':') do
begin
write(s[i]);
i := i + 1;
end;
end.
4)
var
i: integer;
s: string;
begin
readln(s);
i := 1;
while i < s.Length do
begin
if(s[i] = ' ') then s[i] := '.';
if(s.Length - i > 2) then if(s[i] = '.') and (s[i + 1] = '.') and (s[i + 2] = '.') then begin
delete(s, i + 1, 2);
end;
if(s.Length - i > 2) and (i > 2) then if(s[i - 1] = '.') and (s[i] = '.') and (s[i + 1] = '.') then
begin
delete(s, i + 1, 2);
end;
i := i + 1;
end;
writeln(s);
end.