C语言——记一道错题

int main() { int countx=0,x=8421; while(x) { countx++; x=x&(x-1); } printf("countx = %d \n",countx); return 0; } 问题:countx的值输出为多少? 尝试将0xf计算,发现规律应该有多少个1,就需要进行多少次(x=x&(x-1)计算)      验证: 则接下来计算即
相关文章
相关标签/搜索