Код | program Project2;
var s : string[60] = 'sdsgs#d_123_ewat&wea_16489_w,etwe_27_twetw_5_ewr.we_653_fgh'; i : Integer; pmax, lmax : Integer; pt, lt : Integer; ResultStr : string;
begin i := 1; lmax := 0; repeat if s[i] in ['0'..'9'] then Begin lt := 1; while (i <= Length(s)) do if s[i+lt] in ['0'..'9'] then Inc(lt) else Break; pt := i; if lt > lmax then begin lmax := lt; pmax := i; end; i := i + lt; end; Inc(i); until i > Length(s);
ResultStr := Copy(s, 1, pmax - 1) + Copy(s, pt, lt) + Copy(s, pmax + lmax, pt - pmax - lmax) + Copy(s, pmax, lmax) + Copy(s, pt + lt, Length(s) - pt - lt + 1); Writeln(s); Writeln(ResultStr); Readln; end.
|
|