Stimmt, klappt nicht ganz, aber so
Delphi-Quellcode:
var
A: array[0..9] of Word;
I,L,Start: Integer;
B: Boolean;
procedure _Entry;
begin
if B then Result := Result+IntToStr(Start)+'-'+IntToStr (L)+', '
else Result := Result+IntToStr(L)+', ';
B := False;
end;
begin
Result := '';
a[0] := 1982;
a[1] := 1985;
a[2] := 1986;
a[3] := 1987;
a[4] := 1990;
a[5] := 1992;
a[6] := 1993;
a[7] := 1995;
a[8] := 1996;
a[9] := 1998;
B := False;
L := A[Low(A)]; //das erste Jahr
for I := Low(A)+1 to High (A) do
begin
if A[I]=L+1 then
begin
if not B then Start := L;
B := True;
end
else _Entry;
L := A[I]
end;
_Entry;
end;