这个算法是计算bit string 中1的个数.
procedure bitcount(s:bit string)
count:=0;
while s<>0
begin
count:=count=1;
s:=s^(s-1);
end
{count is the number of 1s in s}
其中s:=s^(s-1)是什么意思?
...全文
19823打赏收藏
大家帮我看一道简单的算法题,我实在看不懂.
这个算法是计算bit string 中1的个数. procedure bitcount(s:bit string) count:=0; while s0 begin count:=count=1; s:=s^(s-1); end {count is the number of 1s in s} 其中s:=s^(s-1)是什么意思?