program StringIntersection;
function GetIntersection(const Str1, Str2: string): string;
var
i: Integer;
CommonChars: string;
begin
CommonChars := '';
for i := 1 to Length(Str1) do
begin
if (Pos(Str1[i], Str2) > 0) and (Pos(Str1[i], CommonChars) = 0) then
CommonChars := CommonChars + Str1[i];
end;
GetIntersection := CommonChars;
end;
var
String1, String2, Intersection: string;
begin
String1 := 'php';
String2 := 'python';
Intersection := GetIntersection(String1, String2);
WriteLn('Intersection of "', String1, '" and "', String2, '" is: "', Intersection, '"');
end.
(*
run:
Intersection of "php" and "python" is: "ph"
*)