Janilabo

Untitled

Aug 15th, 2012
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 1.02 KB | None | 0 0
  1. function StrPosAllTCA(TCA: TCharArray; str: string): TIntArray;
  2. var
  3.   h, h2, i, i2, i3, d, o, p, r: Integer;
  4. begin
  5.   h := High(TCA);
  6.   if ((h < 0) or (str = '')) then
  7.     Exit;
  8.   if (h >= 1) then
  9.     for i := (h - d) downto 1 do
  10.       for i2 := (i - 1) downto 0 do
  11.         if (TCA[i] = TCA[i2]) then
  12.         begin
  13.           h2 := High(TCA);
  14.           for i3 := i to (h2 - 1) do
  15.             TCA[i3] := TCA[(i3 + 1)];
  16.           SetLength(TCA, h2);
  17.           Inc(d);
  18.           Break;
  19.         end;
  20.   h := High(TCA);  
  21.   SetLength(Result, Length(str));
  22.   for i := 0 to h do
  23.   begin
  24.     repeat  
  25.       p := PosEx(TCA[i], str, (o + 1));
  26.       if (p > 0) then
  27.       begin
  28.         Result[r] := p;
  29.         o := p;
  30.         Inc(r);
  31.       end;
  32.     until (p <= 0);
  33.     o := 0;
  34.   end;            
  35.   SetLength(Result, r);
  36.   SortTIA(Result);
  37. end;
  38.  
  39. var
  40.   TIA: TIntArray;
  41.  
  42. begin
  43.   TIA := StrPosAllTCA(['I', 'l'], 'Janilabo is a nub. JANILABO = NOOB! loIIol');
  44.   WriteLn(TIAToStr(TIA));
  45.   SetLength(TIA, 0);
  46. end.
Advertisement
Add Comment
Please, Sign In to add comment