Home > Back-end >  For a great god
For a great god

Time:09-17

Letters statistics

1) Linux shell scripting or C language implementation

2) to a specified file case letters (52) in the number of occurrences of statistics and print out the int index [52]. Char c [52] a-z a-z

CodePudding user response:


with loopC [0] 25=A - Z, c [51] 26 -=A - Z, the index is 0, all
Each character ch, read the file if it is A capital letter, index [ch - 'A'] + +, if it is A lowercase letter, index [26 + ch - 'A'] + +, with loop to print out c [I], finally the index [I].

CodePudding user response:

1. The first thing you need to open the file, use fopen, can learn the corresponding function
2 then a characters a cycle of reading, at least over, each read one character at a time, statistics a number of the characters
  • Related