[关闭]
@rulerstorm 2014-06-08T02:39:45.000000Z 字数 322 阅读 1297

coding tricks

理论
[toc]


1. 指定内存空间的初始化

void * memset ( void * ptr, int value, size_t num );


2. 一种对整数数量级的试探技巧

while(w/i) i*=10; 退出时,i即比最高位多1.


3. 简易随机数生成

#include <time.h>
#include <stdlib.h>
srand(time(0))
rand()%100 其中100是范围上限,0是默认下限。


4. 想给int赋一个默认的最小值?

0x8000 0000 (补码)


5. 怎么取一个数字得前几位?

按位“与”

添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注