由买买提看人间百态

topics

全部话题 - 话题: modecount
(共0页)
l*********8
发帖数: 4642
1
As iverson1407 said, the program doesn't work for the number that appears
exactly n/2 times when n is even.
Another problem: probably there is no such number existing in the array.
// Find the number(s) that appear
// Input:
// int * a, input array
// size_t n, length of the array
// Output:
/// int mode[2], store the mode nubmers found.
// return:
// int, how many mode numbers found. (0, 1 or 2)
//
int
FindModeNumber(int *a, size_t n, int modeNumbers[2])
{
if (n<2)
... 阅读全帖
(共0页)