03-1-2012, 05:05 PM | #1 |
Caelondia Represent
Join Date: Jul 2004
Location: A place of hearts and ghosts
Age: 31
Posts: 1,984
|
C++ Help Plz
So, I'm doing an assignment where I have to take a text file, analyze the number of words and distinct words, and then print out the most used words and their frequencies. It works like a charm, but when using large files (like we need to handle) my method of searching through the amount of words to see if it is distinct takes ****ing forever. Can anyone help me make this more efficient?
Here's the code (pastebin so it keeps formatting): http://pastebin.com/80Nr0VrL
__________________
Какой идиот придумал Бутерброд с дикобраза? Он хулиган и бездельник. |
03-1-2012, 05:17 PM | #2 |
the Mathemagician~
|
Re: C++ Help Plz
An easy way to do so that is much more efficient is to loop through every word, and add 1 to array[word] (or create it with a value of 1 if it doesn't exists). Once this is done, you only have to find the biggest value in array[].
|
03-1-2012, 05:39 PM | #3 |
x'); DROP TABLE FFR;--
Join Date: Nov 2010
Posts: 6,332
|
Re: C++ Help Plz
dict() that shit up
|
03-2-2012, 09:56 PM | #4 |
I am leonid
Join Date: Oct 2008
Location: MOUNTAIN VIEW
Age: 35
Posts: 8,080
|
Re: C++ Help Plz
what rubix said
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
|
|