program CommonCharactersCountProgram;
function CountCommonCharacters(str1, str2: string): Integer;
var
i, j: Integer;
commonCount: Integer;
begin
commonCount := 0;
for i := 1 to Length(str1) do
begin
for j := 1 to Length(str2) do
begin
if str1[i] = str2[j] then
begin
Inc(commonCount);
Break; // Move to the next character in str1
end;
end;
end;
CountCommonCharacters := commonCount;
end;
var
str1, str2: string;
commonChars: Integer;
begin
str1 := 'abcdefg';
str2 := 'xayzgoe';
commonChars := CountCommonCharacters(str1, str2);
WriteLn('Number of common characters: ', commonChars);
end.
(*
run:
Number of common characters: 3
*)