OnTheWay2012 埋葬昨天的我，迎来重生的我！
re: 链表实验 OnTheWay 2011-01-09 07:45

re: 令人气愤的现象[未登录] OnTheWay 2010-05-27 19:19
@GunsNRose

@OwnWaterloo

@OwnWaterloo

@vane

unsigned int Drink(unsigned int nBottleNum)
{
unsigned int nTotal = 0;

unsigned int nBitNum = 1;
for(double i = 1 ; i < sizeof(nBottleNum) * 8.0 ; i++)
{
if(pow(2.0, i) > nBottleNum)
{
nBitNum = static_cast<int>(i);
break;
}
}

for (unsigned int i = 1 ; i <= nBottleNum ; i++)
{
cout<<"第"<<i<<"瓶水被以下老鼠喝了"<<flush;
for (unsigned int j = 1 ; j <= nBitNum ; j++)
{
if (0 != (nMask & i))
{
nTotal++;
cout<<j<<" ";
}

}
cout<<endl;
}

return nTotal;
}

@vane

@小时候可靓了

@marco

template<int T>
int smstrlen(char*p)
{
if(p[T]==0)
return T;
return smstrlen<T+1>(p);
}

template<>
int smstrlen<500>(char*p)
{
if(p[500]==0)
return 500;
return -1;
}

int MyStelen(char *str, int size = 0)
{
return (*str++ == '\0') ? size : MyStelen(str, size + 1);
}

(int *)&p - sizeof(int) * 2 ，这句代码就是访问了不应该访问的内存 ，虽然是 - sizeof(int) * 2。

@杨帆

@杨帆

@hoodlum1980

#include <iostream>
#include <bitset>
#include <algorithm>

using namespace std;

size_t GetBitNumOfOne_ByBitSet(unsigned int nValue)
{
const size_t sizeBitNum = 8;
bitset<sizeof(unsigned int) * sizeBitNum> TestBitSet(nValue);
string strContent = TestBitSet.to_string();
return std::count(strContent.begin(), strContent.end(), '1');
}

void main()
{
//测试数据
cout<<GetBitNumOfOne_ByBitSet(0)<<endl;
cout<<GetBitNumOfOne_ByBitSet(1)<<endl;
cout<<GetBitNumOfOne_ByBitSet(2)<<endl;
cout<<GetBitNumOfOne_ByBitSet(123)<<endl;
cout<<GetBitNumOfOne_ByBitSet(0xff)<<endl;
}
@乐蜂专卖店

re: 面试感悟 OnTheWay 2010-03-24 18:24
@billow

re: 面试感悟 OnTheWay 2010-03-24 09:44
@陈梓瀚(vczh)

 < 2023年12月 >
262728293012
3456789
10111213141516
17181920212223
24252627282930
31123456

•