谁有更好的去掉字符串中重复字符的函数。例:
‘0968809’==》‘0968’

解决方案 »

  1.   

    function(str:string):string
    var i:integer;
    vstr:string;
    list:tlist;
    begin
      for i=1 to length(str) do
      begin
        if list.indexof(str[i])<1 then
          list.add(str[i];
          vstr:=vstr+str[i];
      end;
    Result:=vstr;
    end;
      

  2.   

    因为很久没用DELPHI了, 所以有些语法或函数写错了, 自己改改吧
      

  3.   

    "if  list.indexof(str[i])  <1  then "
    应该改为“if  list.indexof(str[i])  <0  then  ”吧!
      

  4.   

    function DeleteRedeclared(S: string): string;
    var
      I: Integer;
    begin
      Result := S;
      for I := Length(Result) downto 1 do
        if Pos(Result[I], Result) <> I then
          Delete(Result, 1, 1);
    end; { DeleteRedeclared }
      

  5.   

    同 zswangII(伴水清清)(职业清洁工)
       他的算法已经够好了,给分吧.