Просмотр полной версии : Как получить случайное число
Как получить случайное число:
1) на промежутке (например от 1 до 100).
2) или из группы разных чисел (не попорядку и нет прогрессии и закономерностей (например 2, 188, 5, 34, 1000).
Math.random
array[Math.random]
что-то не пойму. Например переменной x надо присвоить случайное число от 1 до 100 как скрипт выглядет?
F1:
------------------------------------------------------------------------------
Math.random
Syntax
Math.random();
Arguments
None.
Description
Method; returns a pseudo-random number between 0.0 and 1.0.
Player
Flash 5 or later. In the Flash 4 Player, the methods and properties of the Math object are emulated using approximations and may not be as accurate as the non-emulated math functions supported by the Flash 5 Player.
See also
random
------------------------------------------------------------
random
Syntax
random();
Arguments
value The highest integer for which random will return a value.
Description
Function; returns a random integer between 0 and the integer specified in the value argument.
Player
Flash 4. This function is deprecated in Flash 5; use of the Math.random method is recommended.
Example
The following use of random returns a value of 0, 1, 2, 3, or 4:
random(5);
See also
Math.random
--------------------------------
x = 1+random(100);
x = 1+int(Math.random()*100);
x = 1+Math.floor(Math.random()*100);
Math.random()
Method; returns n, where 0 <= n < 1.
||
Flash Player 4. This function is deprecated in Flash 5; use of the Math.random method is recommended.
Usage
random(value)
Example
The following use of random returns a value of 0, 1, 2, 3, or 4:
random(5);
Работает на vBulletin ® версия 3.7.3. Copyright ©2000-2026, Jelsoft Enterprises Ltd. Перевод: zCarot
Copyright © 1999-2008 Flasher.ru. All rights reserved.