Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var s, smin, smax, stemp: string;
- i, n: longint;
- f: text;
- function comp(a, b: string): boolean;
- var lena, lenb, j: longint;
- begin
- comp := false;
- lena := length(a);
- lenb := length(b);
- if lena < lenb then
- comp := true
- else if lena = lenb then
- begin
- for j := 1 to lena do
- begin
- if a[j] < b[j] then
- comp := true;
- if a[j] <> b[j] then
- break;
- end;
- end;
- end;
- procedure modify;
- begin
- if stemp <> '' then
- begin
- if (smin = '') or comp(stemp, smin) then
- smin := stemp;
- if (smax = '') or comp(smax, stemp) then
- smax := stemp;
- stemp := '';
- end;
- end;
- begin
- assign(f, 'timso.inp'); reset(f);
- read(f, s);
- close(f);
- n := length(s);
- smin := ''; smax := ''; stemp := '';
- for i := 1 to n do
- if (s[i] >= '0') and (s[i] <= '9') then
- begin
- if (s[i] <> '0') or (stemp <> '') then
- stemp := stemp + s[i];
- end
- else
- modify;
- modify;
- assign(f, 'timso.out'); rewrite(f);
- writeln(f, smin);
- write(f, smax);
- close(f);
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement