算法珠玑——基本数据类型(1, 2)
https://leetcode-cn.com/problems/count-odd-numbers-in-an-interval-range/submissions/
class Solution {
public:
int countOdds(int low, int high) {
return low%2 + high%2 + (low%2 && high%2 ? (high-low)/2-1 : (high-low)/2);
}
};