- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
procedure sr(var q, w: string; j, k: integer);
begin
for j := 1 to 100 do
begin
if ord(q[j]) - ord(w[j]) > 0 then begin for k := 1 to pos(' ', q) do write(q[k]);exit; end
else if ord(q[j]) - ord(w[j]) < 0 then begin for k := 1 to pos(' ', w) do write(w[k]);exit; end;
end;
for k := 1 to pos(' ', w) do write(w[k]);
end;
procedure sr2(var q, w, e, r: string; j, k, p: integer);
begin
for j := 1 to 101 do
begin
if ord(q[j]) - ord(w[j]) > 0 then begin r := q;break; end
else if ord(q[j]) - ord(w[j]) < 0 then begin r := w;break;end;
inc(p);
end;
if p>100 then r:=w;
for j := 1 to 100 do
begin
IF E[J]=' ' Then break;
if ord(e[j]) - ord(r[j]) > 0 then begin for k := 1 to pos(' ', e) do write(e[k]);exit; end
else if ord(e[j]) - ord(r[j]) < 0 then begin for k := 1 to pos(' ', r) do write(r[k]);exit; end;
end;
for k := 1 to pos(' ', r) do write(r[k]);
end;
var
st, a, b, c, rd: string;
i, s: integer;
begin
assign(input, 'input.txt'); reset(input);
assign(output, 'output.txt'); rewrite(output);
read(st);
for i := 1 to 102
do
begin
a := a + ' ';
b := b + ' ';
c := c + ' ';
end;
for i := 1 to length(st) do
if st[i] = ' ' then inc(s)
else
case s of
0: a[i] := st[i];
1: b[i - pos(' ', a)] := st[i];
2: c[i - pos(' ', a) - pos(' ', b)] := st[i];
end;
if (a=b) and (b=c) then for i := 1 to pos(' ', a) do write(a[i])
else if (pos(' ', a) > pos(' ', b)) and (pos(' ', a) > pos(' ', c)) then for i := 1 to pos(' ', a) do write(a[i])
else if (pos(' ', b) > pos(' ', a)) and (pos(' ', b) > pos(' ', c)) then for i := 1 to pos(' ', b) do write(b[i])
else if (pos(' ', c) > pos(' ', b)) and (pos(' ', c) > pos(' ', a)) then for i := 1 to pos(' ', c) do write(c[i])
else if (pos(' ', a) = pos(' ', b)) and (pos(' ', b) = pos(' ', c)) then sr2(a, b, c, rd, 0, 0, 0)
else if pos(' ', a) = pos(' ', b) then sr(a, b, 0, 0)
else if pos(' ', c) = pos(' ', b) then sr(c, b, 0, 0)
else if pos(' ', a) = pos(' ', c) then sr(a, c, 0, 0);
end.