0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【カス備忘録】様々な乱数の簡易的な作成方法

Posted at
  • 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
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?