| Код | uses crt;
var word: string;
function execute(s: string): string; var i, start, len, maxlen: integer; comma: boolean; maxstr, str: string; begin start:=1; comma:=false; len:=0; maxlen:=0; for i:=1 to length(s) do begin if s[i]=',' then begin writeln; comma:=true; if len>maxlen then begin maxlen:=len; maxstr:=str; end; len:=0; str:=''; end else if ((s[i]<>',') and (s[i]<>' ')) or ((s[i]=' ') and (not comma)) then begin comma:=false; write(s[i]); str:=str+s[i]; inc(len) end; end; if len>maxlen then begin maxlen:=len; maxstr:=str; end; writeln; execute:=maxstr; end;
begin clrscr; word:=execute('Odessa, Kiev, Lvov, Nikopol, Alushta, Nikolaev'); write('max word=', word); readkey; end.
|
|