Go Back   Flash Flash Revolution > General Discussion > Technology
Register FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
Old 03-1-2012, 05:05 PM   #1
Kibblre
Caelondia Represent
FFR Veteran
 
Kibblre's Avatar
 
Join Date: Jul 2004
Location: A place of hearts and ghosts
Age: 31
Posts: 1,984
Default 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
__________________
Какой идиот придумал Бутерброд с дикобраза? Он хулиган и бездельник.
Kibblre is offline   Reply With Quote
Old 03-1-2012, 05:17 PM   #2
emerald000
the Mathemagician~
Retired StaffFFR Veteran
 
emerald000's Avatar
 
Join Date: Nov 2005
Location: Quebec City
Age: 33
Posts: 1,320
Send a message via Skype™ to emerald000
Default 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[].
emerald000 is offline   Reply With Quote
Old 03-1-2012, 05:39 PM   #3
Reincarnate
x'); DROP TABLE FFR;--
Retired StaffFFR Veteran
 
Reincarnate's Avatar
 
Join Date: Nov 2010
Posts: 6,332
Default Re: C++ Help Plz

dict() that shit up
Reincarnate is offline   Reply With Quote
Old 03-2-2012, 09:56 PM   #4
leonid
I am leonid
Retired StaffFFR Simfile AuthorFFR Music ProducerD7 Elite KeysmasherFFR Veteran
 
leonid's Avatar
 
Join Date: Oct 2008
Location: MOUNTAIN VIEW
Age: 34
Posts: 8,080
Default Re: C++ Help Plz

what rubix said
__________________



Proud member of Team No
leonid is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is On
HTML code is Off

Forum Jump



All times are GMT -5. The time now is 04:44 PM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright FlashFlashRevolution