#include "stdafx.h"
#include "stdlib.h"
void fn(int v)
{
int val = v;
int cnt = 0;
while(val > 0)
{
int t = (val & 0x1);
val >>= 1;
if (t == 1)
cnt++;
}
char s[33];
itoa(v, s, 2);
printf("v[%d %s] 1 cnt[%d]\n", v, s, cnt);
}
void fn1(int v)
{
int val = v;
int cnt = 0;
while(val > 0)
{
cnt++;
val &= val -1;
}
char s[33];
itoa(v, s, 2);
printf("v[%d %s] 1 cnt[%d]\n", v, s, cnt);
}
int _tmain(int argc, _TCHAR* argv[])
{
fn1(630);
return 0;
}