How to get the Value of a TextArea?

How i get the value of some random numbers that has the largest frequency?

  • how i get the value of some random numbers that has the largest frequency i need to write a function that give me the largest frequency of integer random numbers range from 1 to 1000 by using vector the simple: The value xxxxx has the largest frequency of xxxxxx. i start by writing //function to get integer value frequency int Value_frequency(vector<int>v, int& frequency) { what i write here to get the frequency?

  • Answer:

    You are only guarateed to have a number more than once if the vector contains at least 1001 values. This is how I would do it: int count[1000]; for( int k=0; k<v.size(); k++ ) { ...count[v[k]]++; } Now you have the counts in count[], just sort to find the max value. +add Actually, because indexing starts at 0 and your numbers range is [1,1000] then use count[v[k]-1]++; Since you want frequency and not count just divide by v.size().

modulo_f... at Yahoo! Answers Visit the source

Was this solution helpful to you?

Other answers

Well, in Lua, you would do this: local numbers = {1,7,0,10,17} local highest = 0 for i, v in pairs(numbers) do if v > highest then highest = v end end print(highest) I don't know how you would transfer that into... whatever language your using, but you can use loops.

You see when we simulate large number of trials then the probability of all the numbers will be same. Yes. You have make infinite trails. So, question of finding a number with highest frequency becomes debatable. Anyhow, Vector can hold objects. Why dont you think of using set for the same random number and frequency. If you want to maintain vector then you can define a class which contains a number and its frequency along with methods to increment that can be maintained in the vector.

James Bond

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.