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)計算)      驗證: 則接下來計算即
相關文章
相關標籤/搜索