參考:http://blog.csdn.net/BrilliantEagle/article/details/38532845
參考:http://blog.csdn.net/a83610312/article/details/11713113
參考:http://blog.csdn.net/Nozuowilldie/article/details/48632773
參考:http://www.cppblog.com/hardtry/archive/2011/10/08/157556.html
騰訊2011.10.15校園招聘筆試題
http://blog.csdn.net/zhangyuehuan/article/details/22221071
java 隨機數生成:
Math.random() 生成 大於等於0.0 且小於 1.0 的double 型隨機數
( 0.0 <= Math.random() < 1.0 )
可以使用它便攜簡單了表達式,生成任意範圍的隨機數。
例如:
(int)(Math.random() * 10) 返回 0 ~ 9 之間的一個隨機整數
50 + (int)(Math.random() * 50) 返回 50 ~ 99 之間的一個隨機整數
通常
a + Math.random() * b 返回 a ~ a+b 之間的一個隨機整數 ,不包括a+b 。
其他:
new Random().nextInt(7) + 1;