• Post Reply Bookmark Topic Watch Topic
  • New Topic

Finding the most common value in a number array.  RSS feed

 
Annalily Blake
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm stuck. I need to be able to decrypt a code: basically, the program will take a file that is just a long string of mixed up letters, (think sdase had adkt sort of thing) and decrypt it. I have the program set to make a char array, and so I made the char arrayinto a new int array, with the ASCII values, what I want to be able to do now is have the program look at it and identify the number that occurs the most.

Simplified: I need to find the number that occurs most often in an int array.
I have this, and I'm 99% it's way off, so I need help in trying to figure out how to do this:
 
fred rosenberger
lowercase baba
Bartender
Posts: 12563
49
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you should never write a single line of code unless you can first describe how to do it in English (or whatever natural language you choose) to a small child who only has pencil and paper (and an eraser).

Once you have that, you simply it through several iterations. Only then do you write a single line of code.

Having said that...why do you think your code it off? What do you think is wrong with it? What happens when you run/test it?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!