Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program challenge9;
- type TLowAlpha = 'a'..'z';
- const LOWALPHA : set of char = ['a'..'z'];
- DIGITS : set of char = ['0'..'9'];
- FILE_NAME = 'challenge9_list.txt';
- var alpha : array[TLowAlpha] of byte = (0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);
- i : TLowAlpha;
- sumdigit : smallint = 0;
- f : text;
- s : string = '';
- begin
- assign(f, FILE_NAME);
- reset(f);
- while not eof(f) do begin
- readln(f, s);
- if s[1] in DIGITS then
- inc(sumdigit, ord(s[1]) - ord('0'))
- else if s[1] in LOWALPHA then
- inc(alpha[s[1]]);
- end;
- close(f);
- writeln('Sum = ', sumdigit);
- for i := 'a' to 'z' do
- if alpha[i] <> 0 then
- writeln(i, ' = ', alpha[i]);
- readln; // pausa
- end.
Advertisement
Add Comment
Please, Sign In to add comment