So, I'm trying to create a basic program for learning the basics of C ++, I generate 100 random numbers from 0 to 100 and store them in a vector, then I show the sum, average, average, mode, high and low vector. I have everything else except the mode in which I am stuck. Here is the code I have.
int modeFunction() { numMode = 0; count = 0; for (int n = 0; n < 100; n++) { for (int y = 0; y < 100; y++) { if (numVector.at(y) == numVector.at(n)) { numMode = numVector.at(y); count++; } } } return numMode; }
After that, I get stuck, because in my mind, which should work, but it is not. He simply puts the last number, usually 100. Any help would be greatly appreciated.
Cistoran
source share