The non English parts of the question it's just translation.Please answer. I will give thumbs up
To solve this problem we take a 2D array Matrix 20x20, an alpha array that contains all the small and capital letters in it.
And a freq array to record the frequency of each letter.
Then we scan the Matrix array one letter at a time. And see the position of that letter in alpha array and incrementing the value at that position in the freq array.
For eg, current element scanned in Matrix is 'k', then the position of 'k' in alpha is 11. So, freq[11] will be incremented implying that one 'k' is found in Matrix.
CODE:
program Alphabet;
uses
SysUtils;
var
i: Integer;
j: Integer;
k: Integer;
alpha: String;
Matrix: array[1..20, 1..20] of char;
freq : array[1..52] of Integer;
begin
Randomize;
alpha:='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
for k := 1 to 52 do
freq[k] := 0; //initializing frequency of each letter to 0
for i := 1 to 20 do
for j := 1 to 20 do
Matrix[i, j] := alpha[Random(53)]; //53 =
26(small)+26(capital)+1
for i := 1 to 20 do
begin
for j := 1 to 20 do
Write(Matrix[i, j], ' ');
WriteLn;
end;
for i := 1 to 20 do
begin
for j := 1 to 20 do
begin
for k:=1 to 52 do
if Matrix[i,j] = alpha[k] then //if letter found
freq[k]:= freq[k]+1; // then increment frequency of that
letter
end;
end;
WriteLn;
//printing the alphabet and its frequency:
for k := 1 to 52 do
begin
Write(alpha[k],' : ',freq[k]);
WriteLn;
end;
end.
OUTPUT:
The non English parts of the question it's just translation.Please answer. I will give thumbs up...