Posted by James on May 22, 2003
Hello I am wrting (well 75% done) a program that reads a text file character by character and counts the number of each letter in the file. It then displays the frequency of each letter. eg.. A B C D E F G H I J K L M N O P Q R S T U V W X Y Z 46 5 26 26108 27 15 12 49 0 2 25 3 49 24 21 10 61 28 40 18 6 6 9 16 4 This is what I have so far program frequency; {$APPTYPE CONSOLE} uses SysUtils; const FileName = Frequency.dpr'; type LetterRange = 'A'..'Z'; ArrayType = array[ LetterRange ] of integer; procedure initialise( var frequencies : ArrayType );
var
index : LetterRange;
begin
for index := 'A' to 'Z' do
frequencies[ index ] := 0;
end; procedure
populate( var frequencies : ArrayType );
var f : textfile;
ch : char;
begin
//
This is where I am having trouble...........any help?
end;
procedure display( frequencies : ArrayType ); var
index : LetterRange;
begin
for index := 'A' to 'Z' do
write( index : 3 );
writeln;
for index := 'A' to 'Z' do
write( frequencies[ index ] : 3 );
writeln; end;
var frequencies : ArrayType;
begin
initialise( frequencies ); populate( frequencies );
display( frequencies );
readln;
end.
****************************************************
Can someone please help me with this?
Related Articles and Replies:
[ Delphi
Forum ] [ DelphiLand: free Delphi source code, tips, tutorials ]
|