Hello wonder if you could help me please..

Basically I'm trying to implement a script where it searches through a file and sees the most popular word..

I've got it doing it like this:

Squence: 0 0
Squence: 1 0
Squence: 2 0
Squence: 3 0
Squence: 4 0
Squence: 5 0
Squence: 6 0
Squence: 7 0
Squence: 8 0
Squence: 9 4
Squence: 10 0
Squence: 11 0
Squence: 12 0
Squence: 13 0
Squence: 14 0
Squence: 15 0
Squence: 16 0
Squence: 17 0
Squence: 18 0
Squence: 19 0
Squence: 20 0
Squence: 21 0
Squence: 22 0
Squence: 23 1
Squence: 24 0
Squence: 25 0
Squence: 26 0

And then I'd take the most frequent word (9) now i've tried this:

for (int m=0; (m < 27); m++)
    maxNum = max(numbers[m], numbers[m]);

Doesn't work.. Also, does anyone know how I would find the actual sequence number, from this? i.e. it finds the maximum number (4) and then displays 9...

Thanks =)

Edited by phorce: n/a

5 Years
Discussion Span
Last Post by raptr_dflo

Well max(numbers[m], numbers[m]) presumably returns the maximum of the same value provided twice. Which is obviously a silly thing to ask for. My recommendation: stop trying to do it "the cool way" and actually think about what you're trying to accomplish, and how to go about accomplishing it one step at a time:
1) Read a line of info.
2) Determine whether you should save it:
2a) If yes, save what you need.
2b) If no, then skip it.
3) Repeat.

What info do you -want- at the end? What info do you also need to save so you can tell whether the next line you read is "better" than whatever you have saved so far? What should you do to make sure you save the info from the first line? What should your program do if there are no lines at all?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.