C++ Help Plz

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Kibblre
    Caelondia Represent
    • Jul 2004
    • 1984

    #1

    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):
    Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
    Какой идиот придумал Бутерброд с дикобраза? Он хулиган и бездельник.
  • emerald000
    the Mathemagician~
    • Nov 2005
    • 1320

    #2
    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[].

    Comment

    • Reincarnate
      x'); DROP TABLE FFR;--
      • Nov 2010
      • 6332

      #3
      Re: C++ Help Plz

      dict() that shit up

      Comment

      • leonid
        I am leonid
        FFR Simfile Author
        FFR Music Producer
        • Oct 2008
        • 8080

        #4
        Re: C++ Help Plz

        what rubix said



        Proud member of Team No

        Comment

        Working...