归档

归档

博客园 首页 新随笔 联系 订阅 管理

2007年7月19日 #

摘要: 1/**//************************************************************************/ 2/**//* Rotate String by K, for example the orignal string is "abcdefgh" 3 Then the Rotated String is "defghabc"*/ 4... 阅读全文
posted @ 2007-07-19 20:58 xianzi0 阅读(210) 评论(0) 推荐(0)

摘要: 1template 2int BinarySearch(DataType *a , int n , DataType value) 3{ 4 assert(a != NULL); 5 assert(n > 0); 6 int index = -1; 7 int l , u , m; 8 l = 0; 9 u = n - 1;10 while (l ... 阅读全文
posted @ 2007-07-19 20:00 xianzi0 阅读(117) 评论(0) 推荐(0)

摘要: /**//************************************************************************//**//* 以概率k/n在0-n中选出k个不重复随机数 *//**//*****************************************************... 阅读全文
posted @ 2007-07-19 17:10 xianzi0 阅读(241) 评论(0) 推荐(0)

摘要: 1/**//************************************************************************/ 2/**//* swap two value without the temp variable */... 阅读全文
posted @ 2007-07-19 16:29 xianzi0 阅读(236) 评论(0) 推荐(0)

摘要: 1#define NBITSPERUINT 32 2#define MASK 0x01F 3#define SHIFT 5 4#define NMAX 10000000 5 6unsigned int a[1 + NMAX / NBITSPERUINT]; 7 8void set(int i) 9{10 a[i >> SHIFT] |= (1 > SHIFT] &= ~(1 > SHIFT... 阅读全文
posted @ 2007-07-19 16:25 xianzi0 阅读(249) 评论(0) 推荐(0)