반응형
쉬어가는 문제2
Check if all digits of the given integer are even. Example For n = 248622, the output should be evenDigitsOnly(n) = true; For n = 642386, the output should be evenDigitsOnly(n) = false. |
code>>
bool evenDigitsOnly(int n) {
while (n > 0)
{
if ((n % 10 % 2)) return false;
n = n / 10;
}
return true;
}
반응형
'알고리즘 > codefights' 카테고리의 다른 글
28>alphabeticShift (0) | 2017.07.06 |
---|---|
27>variableName (0) | 2017.07.06 |
25>arrayReplace (0) | 2017.07.06 |
24>minesweeper (0) | 2017.07.06 |
23>boxBlur (0) | 2017.07.05 |