>553
線形合同法は下位にあるビットほど質が悪い

(int)((rand() / ((double)RAND_MAX+1.0f)) * n);

ttp://ja.wikipedia.org/wiki/Rand より
0からn-1の範囲だが