Create a program: Given a large text file with multiple strings, what would be the most efficient way to read the text file and count how many and which word appears the most repated word in a text file Output : the first 25 most repated words The text file's size is unknown. I add an image for output File.txt: ================================================================= Chapter 1 The house stood on a slight rise just on the edge of the village. It stood on its own and looked over a broad spread of West Country farmland. Not a remarkable house by any means - it was about thirty years old, squattish, squarish, made of brick, and had four windows set in the front of a size and proportion which more or less exactly failed to please the eye. The only person for whom the house was in any way special was Arthur Dent, and that was only because it happened to be the one he lived in. He had lived in it for about three years, ever since he had moved out of London because it made him nervous and irritable. He was about thirty as well, dark haired and never quite at ease with himself. The thing that used to worry him most was the fact that people always used to ask him what he was looking so worried about. He worked in local radio which he always used to tell his friends was a lot more interesting than they probably thought. It was, too - most of his friends worked in advertising. It hadn't properly registered with Arthur that the council wanted to knock down his house and build an bypass instead. At eight o'clock on Thursday morning Arthur didn't feel very good. He woke up blearily, got up, wandered blearily round his room, opened a window, saw a bulldozer, found his slippers, and stomped off to the bathroom to wash. Toothpaste on the brush - so. Scrub. Shaving mirror - pointing at the ceiling. He adjusted it. For a moment it reflected a second bulldozer through the bathroom window. Properly adjusted, it reflected Arthur Dent's bristles. He shaved them off, washed, dried, and stomped off to the kitchen to find something pleasant to put in his mouth. Kettle, plug, fridge, milk, coffee. Yawn. The word bulldozer wandered through his mind for a moment in search of something to connect with. The bulldozer outside the kitchen window was quite a big one. He stared at it. "Yellow," he thought and stomped off back to his bedroom to get dressed. Passing the bathroom he stopped to drink a large glass of water, and another. He began to suspect that he was hung over. Why was he hung over? Had he been drinking the night before? He supposed that he must have been. He caught a glint in the shaving mirror. "Yellow," he thought and stomped on to the bedroom.
C++
Create a program:
Given a large text file with multiple strings, what would be the most efficient way to read the text file and count how many and which word appears the most repated word in a text file
Output : the first 25 most repated words
The text file's size is unknown.
I add an image for output
File.txt:
=================================================================
Chapter 1
The house stood on a slight rise just on the edge of the village.
It stood on its own and looked over a broad spread of West
Country farmland. Not a remarkable house by any means - it was
about thirty years old, squattish, squarish, made of brick, and
had four windows set in the front of a size and proportion which
more or less exactly failed to please the eye.
The only person for whom the house was in any way special was
Arthur Dent, and that was only because it happened to be the one
he lived in. He had lived in it for about three years, ever since
he had moved out of London because it made him nervous and
irritable. He was about thirty as well, dark haired and never
quite at ease with himself. The thing that used to worry him most
was the fact that people always used to ask him what he was
looking so worried about. He worked in local radio which he
always used to tell his friends was a lot more interesting than
they probably thought. It was, too - most of his friends worked
in advertising.
It hadn't properly registered with Arthur that the council wanted
to knock down his house and build an bypass instead.
At eight o'clock on Thursday morning Arthur didn't feel very
good. He woke up blearily, got up, wandered blearily round his
room, opened a window, saw a bulldozer, found his slippers, and
stomped off to the bathroom to wash.
Toothpaste on the brush - so. Scrub.
Shaving mirror - pointing at the ceiling. He adjusted it. For a
moment it reflected a second bulldozer through the bathroom
window. Properly adjusted, it reflected Arthur Dent's bristles.
He shaved them off, washed, dried, and stomped off to the kitchen
to find something pleasant to put in his mouth.
Kettle, plug, fridge, milk, coffee. Yawn.
The word bulldozer wandered through his mind for a moment in
search of something to connect with.
The bulldozer outside the kitchen window was quite a big one.
He stared at it.
"Yellow," he thought and stomped off back to his bedroom to get
dressed.
Passing the bathroom he stopped to drink a large glass of water,
and another. He began to suspect that he was hung over. Why was
he hung over? Had he been drinking the night before? He supposed
that he must have been. He caught a glint in the shaving mirror.
"Yellow," he thought and stomped on to the bedroom.
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 2 images