public class Solution {// you need to treat n as an unsigned valuepublic int hammingWeight(int n){int res = 0;while (n != 0){res += 1;n &= n - 1;// 把最后一个出现的 1 改为 0,和 lowbit 有异曲同工之妙}return res;}
}
面试题5:函数调用的过程
C 中函数的调用包含参数入栈、函数跳转、保护现场、回复现场等过程,重点过程如下: (1)将函数的参数压入栈中,从右至左压入。 (2)调用函数时,将当…