1
private
int
CountOne(
int
num)
2 {
3 int count = 0;
4 while (num != 0)
5 {
6 count += num % 10 == 1 ? 1 : 0;
7 num /= 10;
8 }
9 return count;
10}
2 {
3 int count = 0;
4 while (num != 0)
5 {
6 count += num % 10 == 1 ? 1 : 0;
7 num /= 10;
8 }
9 return count;
10}