Thema: Delphi Zwei Arrays vergleichen

Einzelnen Beitrag anzeigen

CB2206

Registriert seit: 4. Feb 2003
Ort: Kaarst
13 Beiträge
 
Delphi 7 Enterprise
 
#2
  Alt 4. Feb 2003, 08:02
Code:
function in_array(bla: integer; arr: array of integer): Boolean
begin
  result := false;
  for a := 0 to Length(arr) do
    if (arr[a] = bla) then begin
      result := True;
      exit;
    end;
end;


{...}
SetLength(array3, 0);
for a := 0 to length(array1) - 1 do
  if not in_array(array1[a], array2) then begin
   SetLength(array3, Length(array3) + 1);
   array3[Length(array3) - 1] := array1[a];
  end;
end;

SetLength(array4, 0);
for a := 0 to length(array2) - 1 do
  if not in_array(array2[a], array1) then begin
   SetLength(array4, Length(array4) + 1);
   array4[Length(array4) - 1] := array2[a];
  end;
end;
{...}
Gruß
CB
  Mit Zitat antworten Zitat