如题,比如一个数组为[A1][一号],[A1][二号],[A2][一号],[A2][二号],[A2][三号],[A3][一号]
如何只得到A1,A2,A3,重复的值就不要了...

解决方案 »

  1.   

    //tstringlist举例,var
    tempList,strList:TStringList;
    i:Integer;
    begin
    strList:= TStringList.Create;
    tempList:= TStringList.Create;
    try
    strList.Add( 'aa' );
    strList.Add( 'aa' );
    strList.Add( 'aa' );
    strList.Add( 'aa' );
    strList.Add( 'bb' );
    strList.Add( 'bb' );
    strList.Add( 'bb' );
    for i:=0 to strList.Count-1 do
    begin
    if tempList.IndexOf( strList.Strings[ i ] ) = -1 then
    begin
    tempList.Add( strList.Strings[ i ] );
    end else
    begin
    //重复记录。+1
    end;
    end;
    for i:=0 to tempList.Count-1 do
    begin
    self.Memo1.Lines.Add( tempList[ i ] );
    end;
    finally
    tempList.Free;
    strList.Free;
    end;