home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Usenet 1994 October
/
usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso
/
unix
/
volume17
/
contest-prog
/
part02
/
prob2.txt
< prev
next >
Wrap
Text File
|
1989-02-06
|
1KB
|
46 lines
Problem 2: Character count.
For all the lines in a file, count the occurrences of the
various characters in that file.
The input file will be a text file of unknown length, but
with each line guaranteed to be less than 80 characters long.
The input file may contain tabs (ascii octal 011), blanks,
and all the printable characters, as well as newlines.
Do not attempt to count newlines; only tabs, blanks, and printable
characters.
Your output should consist of two integers per line. The leftmost
should be the ascii character printed in decimal form, the rightmost
should be the count of the character.
BUT: do not output zero-counts. That is: do not print any line
for which the count is zero.
Example:
time for all
good men to
come to the aid of
(note that the word "good" is preceded by a tab-character).
Should produce:
9 1 <this is the tab>
32 8 <this is "blank">
97 2 <this is "a">
99 1 <etc., and of course, you don't
100 2 print these comments>
101 4
102 2
103 1
104 1
105 2
108 2
109 3
110 1
111 7
114 1
116 4