除了不用想就知道的
int a = xxx;
if(a % 2 == 1)
std::cout << "odd" << std::endl;
else
std::cout << "even" << std::endl;
今天无意中发现可以通过位运算更快速的得到结果
int a = xxx;
if(a & 1 == 1)
std::cout << "odd" << std::endl;
else
std::cout << "even" << std::endl;