Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {==============================================================================]
- Explanation: Returns all positions of TSA which match with str.
- [==============================================================================}
- function TSAPosEx(TSA: TStrArray; str: string): TIntArray;
- var
- i, r, h: Integer;
- begin
- h := High(TSA);
- if (h > -1) then
- begin
- SetLength(Result, (h + 1));
- for i := 0 to h do
- if (TSA[i] = str) then
- begin
- Result[r] := i;
- Inc(r);
- end;
- end;
- SetLength(Result, r);
- end;
- begin
- WriteLn(TIAToStr(TSAPosEx(['a', 'b', 'c', 'd', 'c', 'b', 'a'], '_')));
- WriteLn(TIAToStr(TSAPosEx(['a', 'b', 'c', 'd', 'c', 'b', 'a'], 'a')));
- WriteLn(TIAToStr(TSAPosEx(['a', 'b', 'c', 'd', 'c', 'b', 'a'], 'b')));
- WriteLn(TIAToStr(TSAPosEx(['a', 'b', 'c', 'd', 'c', 'b', 'a'], 'c')));
- WriteLn(TIAToStr(TSAPosEx(['a', 'b', 'c', 'd', 'c', 'b', 'a'], 'd')));
- WriteLn(TIAToStr(TSAPosEx(['a', 'b', 'c', 'd', 'c', 'b', 'a'], 'x')));
- end.
Advertisement
Add Comment
Please, Sign In to add comment