要在C#中使用类型的拓展方法,可在一个类中中通过指定static的方法,将Type通过this方式作为第一个参数传入,如给Random增加一个NextFloat方法 public static class Extension { public static byte[] N...
分类:
其他好文 时间:
2014-08-27 16:00:37
阅读次数:
137
还是去年的时候有同事随口问我在javascript中怎么把小数转换成整数(去掉小数位),当时我回答直接用parseInt。其实那时候也没有仔细考虑这个问题还有没有其他的方法。不过最近在看别人一篇博文里的代码时,发现他这么写代码var random = (Math.random() * 2) | 0;...
分类:
编程语言 时间:
2014-08-26 22:40:26
阅读次数:
243
很适合初学者:第一种方法用while循环。记得while的条件,小心死循环。 public void BuildRandom() { int[] i = new int[10]; Random r = new Random(); ...
分类:
其他好文 时间:
2014-08-26 13:06:06
阅读次数:
141
在javascript中按位取反再取反可以将一个浮点数的转化为整形,而且其效率要比parseInt高出将近一倍
var start = new Date().getTime();
for (var i = 0; i < 10000000; i++) {
var a = Math.random() * 5;
~~a;
}
console.info(new Date().getTime...
分类:
编程语言 时间:
2014-08-26 00:35:45
阅读次数:
221
To follow the path: look to the master,(寻找大师) follow the master,(跟随大师) walk with the master,(与大师同行) see through the master,(观摩大师) become the master.(成...
分类:
其他好文 时间:
2014-08-26 00:06:05
阅读次数:
231
例1:彩票生成器 36选7.方法一:int[] a = new int[7]; Random ran = new Random(); //生成7个数 for (; a[6] == 0; ) { ...
分类:
其他好文 时间:
2014-08-25 01:06:43
阅读次数:
185
最近忙着新项目的框架搭建,实在是太忙了···boost有很多随机引擎就不一一介绍了,一般常用mt19937内存效率质量折中,rand48算法效率最高内存占用小质量一般 1 #pragma once 2 #include 3 #include 4 #include 5 6 template 7...
分类:
其他好文 时间:
2014-08-25 01:03:53
阅读次数:
400
//36选7生成彩票 不许产生重号 /* Random b = new Random(); int[] a = new int[7]; for (int i = 0; i { int t = a[m - 1]; a[m - 1] = a[m]; a[m] = t; } } } for(int i.....
分类:
其他好文 时间:
2014-08-23 16:48:01
阅读次数:
299
LeetCode: Copy List with Random PointerA linked list is given such that each node contains an additional random pointer which could point to any node ...
分类:
其他好文 时间:
2014-08-23 12:34:30
阅读次数:
193
#include
#include
#include
char x,y,ty,ty1,zhuan,line1=0,line2=0,ss[16],hol[10][29]={0},a[4][2]={0};
int score1=0,speed=1000;
void unit(char,char,char); void dl(int);
void block(cha...
分类:
数据库 时间:
2014-08-22 10:57:46
阅读次数:
358