Home > Back-end >  Ask bosses help text file retrieval and count words
Ask bosses help text file retrieval and count words

Time:09-16

Asked programming for a text file, each word does not contain Spaces and is not an inter-bank, word is composed character sequences and case sensitive: statistics the number of occurrences of a given word in a text file; Retrieve the output a word line number appears in the text, in the bank and the number of occurrences of position, to achieve the design requirements can be divided into three parts: first, establish a text file, the file name with the keyboard input by the user; Second, the given word count, input a word does not contain Spaces, statistical output occurrences of the word in a text; Thirdly to retrieve a given word, input a word, retrieval and output of the words in the line number, the number of occurrences of in the bank and the relevant position in the bank,

[ color=# 000000] can be BF and KMP pattern matching [/color]

CodePudding user response:

After reading the text, press the space division, divided into the content of the map after the map key words, the value can be custom objects, object properties is: number, line number, position...

CodePudding user response:

The simplest is to choose the delimiter, then you can use a dictionary, convenient query results
  • Related