You could use an if to detect the number, the question is where would you save the count.
It depends on the range of numbers. If a small range you could use an array.
NormR1
Posting Sage
7,742 posts since Jun 2010
Reputation Points: 1,158
Solved Threads: 793
Skill Endorsements: 16
You could use an array indexed by the number.
NormR1
Posting Sage
7,742 posts since Jun 2010
Reputation Points: 1,158
Solved Threads: 793
Skill Endorsements: 16
create an array of ints with 99 elements.
iterate over your vectorf:
newArray[foundNumber-1] += 1;
stultuske
Industrious Poster
4,372 posts since Jan 2007
Reputation Points: 1,318
Solved Threads: 610
Skill Endorsements: 24
how to iterate it into the vector.
Can you explain?
Are trying to copy array contents to the vector?
NormR1
Posting Sage
7,742 posts since Jun 2010
Reputation Points: 1,158
Solved Threads: 793
Skill Endorsements: 16
What method would I use in order to count the numbers in the output... Like how many 1's and how many 2's etc. etc.
Wouldn't it be much easier if you add 1 to a counter exactly after the generated number
//your number generator code
for (int i = 1; i < 10000; i++) {
int rand = generator.nextInt(97);
vect.add(rand);
vect.add(Math.abs(generator.nextInt()) % 99);
//use a loop will add number instance to a counter
for (int j = 1; j < 99; j++) {//iterate 1-99 for the array's index
if(vect.get(i)==j)//once found
//you add 1 to the array with the same index as j... check stultuske's post
}
}
zeroliken
Nearly a Posting Virtuoso
1,346 posts since Nov 2011
Reputation Points: 214
Solved Threads: 205
Skill Endorsements: 14
we already suggested (at least) two ways to do so.
what have you tried, how have tried it.
show us the code in which you tried it and tell us what it's doing wrong
stultuske
Industrious Poster
4,372 posts since Jan 2007
Reputation Points: 1,318
Solved Threads: 610
Skill Endorsements: 24