Java中存在着两种Random函数:一、java.lang.Math.Random:调用这个Math.Random()函数能够返回带正号的double值,该值大于等于0.0且小于1.0,即取值范围是[0.0,1.0)的左闭右开区间,返回值是一个伪随机数,在该范围内(近似)均匀分布。1 Math.R...
分类:
编程语言 时间:
2014-07-07 11:33:46
阅读次数:
272
一、Random生成随机数重复的问题 Random在生成随机数的时候,如果生成的时间非常短,那么很可能会出现生成的随机数重复的问题。 示例: static void Main(string[] args) { for (int i = 0; i <...
分类:
其他好文 时间:
2014-07-07 09:49:21
阅读次数:
352
??
垃圾回收用来实现内存的自动管理(automatic management),区别于人工管理(manual management)。人工管理内存容易出现的问题:
1)悬垂指针,dangling pointer
2)重复回收,Double free
3)内存泄露,memory leak
历史
垃圾回收的概念及技术由John McCarthy于1959年发明,应用于List...
分类:
其他好文 时间:
2014-07-03 16:34:03
阅读次数:
194
1:函数名为指针
首先,在C语言中函数是一种function-to-pointer的方式,即对于一个函数,会将其自动转换成指针的类型.如:
1 #include
2
3 void fun()
4 {
5 }
6
7 int main()
8 {
9 printf("%p %p %p\n", &fun, fun, *fun);
10 return 0...
分类:
编程语言 时间:
2014-07-03 13:30:17
阅读次数:
363
#define BTS_SAFE_DELETE(POINTER) \do { if (POINTER != 0) { BTS_DELETE(POINTER); POINTER = 0;} \} while (0)注意:宏定义必须在一行,否则报错!\ 表示本行未结束, 没有该连接符时,直接换行编译器会...
分类:
其他好文 时间:
2014-07-03 10:25:27
阅读次数:
186
1.让每次启动程序运行都能产生不同的随机数:#include int main(){ srand(time(0));// set a new seed for random function}2.产生随机数在srand statement 之后:(1)产生0到a的随机数:rand%(a+1); .....
分类:
其他好文 时间:
2014-07-03 09:36:33
阅读次数:
171
VC中常见编译错误(转载看看)1)disable#pragma warning (disable: 4311 4312) //指针类型强制转化,大小不完全匹配warning C4311: ''type cast'' : pointer truncation from ''TriNode *const...
分类:
其他好文 时间:
2014-07-03 07:01:57
阅读次数:
214
生成随机字符串利用Math.random和toString生成随机字符串。这里的技巧是利用了toString方法可以接收一个基数作为参数的原理,这个基数从2到36封顶。如果不指定,默认基数是10进制。略屌! function generateRandomAlphaNum(len) { var rd....
分类:
编程语言 时间:
2014-07-02 23:57:55
阅读次数:
401
Pick-up sticks
Problem Description
Stan has n sticks of various length. He throws them one at a time on the floor in a random way. After finishing throwing, Stan tries to find the top sticks,...
分类:
其他好文 时间:
2014-07-02 15:29:53
阅读次数:
295
importrandom
#引入随机函数
ab=range(1,100)
#随机数取值范围
an=random.smaple(ab,4)
#在100以内的数获取4个随机数。
print(an)
#打印这4个随机数
分类:
编程语言 时间:
2014-07-02 06:29:10
阅读次数:
209