如何优雅的写C++代码(一)

// get the greatest power of two that is a divisor of n:
	return n&-n;
	
	
// swap two integers a and b:
	a^=b^=a^=b;
	a^=b, b^=a, a^=b;
	
// check whether a (nature number > 1) is a power of two or not:
	return ( ! ( x & (x-1)));
	return (x&-x) == x;
	
// count number of bits set in v:
	for( int i=0; v; i++)
		v &= v - 1;
	
	

// copy two char array
	while(*s++ = *t++);
	
// binary search
	int left = 0, right = N;
	for( int mid=(left+right)>>1; right-left>1; mid = left + (right-left)>>1)
		(arr[mid] > x ? left : right ) = mid;
	return right;

如何优雅的写C++代码(一),布布扣,bubuko.com

如何优雅的写C++代码(一)

上一篇:css3动画


下一篇:升级vs更新,用词莫忘准确(附PHP版本升级教程)