I have a problem with defining a multiple dimension
Functions ToUpper and ToLower converts capital to small.
The main function of this code is to count how many times each character appeared in an input. Only letters a-z and numbers 0-9.
VAR
c: char;
Counts: Array['0'..'9','a'..'z'] of Integer;
i : Integer;
Begin
For c := 'a' to 'z' do
Counts[c] := 0;
For c := '0' to '9' do
Counts[c] := 0;
While not EOF do
Begin
Read(c);
c := ToLower(c);
If ( c >= 'a' ) and ( c <= 'z' ) then
Counts[c] := Counts[c] + 1;
if ( c >= '0' ) and ( c <= '9' ) then
Counts[c] := Counts[c] + 1;
end;
For c := 'a' to 'z' do
If Counts[c] <> 0 then
WriteLn(c,Counts[c]);
end.