-
Notifications
You must be signed in to change notification settings - Fork 84
/
rando.cpp
70 lines (48 loc) · 1.07 KB
/
rando.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
//Author: Kevin Buffardi
#include "rando.h"
#include <string>
#include <vector>
/**
* Determines if either first or second parameter is evenly
* divisible by the other.
**/
bool Rando::isDivisibleBy(int first, int second)
{
return true;
}
/**
* Determines, without case sensitivity, whether the parameter is
* if read either backwards (right-to-left) or forwards (left-to-right)
**/
bool Rando::isPalindrome(std::string eval)
{
return true;
}
/**
* Returns the digit {0...9} that occurs the most often within the parameter
* or returns -1 if there is no single digit that occurs more often than all
* the others
**/
int Rando::mostPopularDigit(unsigned int num)
{
int most = 0;
int popular = -1;
int current;
std::vector <int> digitCount(10,0);
while( num > 9 )
{
current = num%10;
digitCount[current]++;
num = num/10;
}
digitCount[num]++;
for(int i=0; i<digitCount.size(); i++)
{
if( digitCount[i] > most )
{
most = digitCount[i];
popular = i;
}
}
return popular;
}