- 0以上N以下の乱数:
rand() % (N + 1) - M以上N以下の乱数:
rand() % (N - M + 1) + M - x以外の0以上N以下の整数:
(x + (rand() % N + 1)) % (N + 1) - 0以上1以下の実数:
(double)rand() / RAND_MAX - M以上N以下の実数:
(double)rand() / RAND_MAX * (N - M) + M
Register as a new user and use Qiita more conveniently
- You get articles that match your needs
- You can efficiently read back useful information
- You can use dark theme