用位数组计算整数中1的个数
摘要:
//// main.c// bitcounts//// Created by Cheney Shen on 11-4-16.// Copyright 2011年 __MyCompanyName__. All rights reserved.//#include <stdio.h>static int bitcounts[] = {0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4};int bitcount(unsigned int u) { int n = 0; for(; u != 0; u >>= 4) n += bitc 阅读全文
posted @ 2011-04-16 03:25 Cheney Shen 阅读(326) 评论(0) 推荐(0) 编辑