---
title: "位运算"
author: "SwordAndFlame"
date: "2011-08-15T10:40:42Z"
tags: []
categories: ["编程语言"]
slug: "untitled"
draft: false
lastmod: "2011-08-15T10:40:42Z"
id: 1149320
url: "https://swordandflame.iteye.com/blog/1149320"
---

统计１的个数

int count(int x)  
{  
    int res=0;  
    while(x){  
        res++;  
        x&=x-1;  
    }  
    return res;  
}