Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. random number

random number

Scheduled Pinned Locked Moved C / C++ / MFC
tutoriallounge
4 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • W Offline
    W Offline
    wong1907
    wrote on last edited by
    #1

    Hello, I want to ask how to generate a random number which is lie between 0 and n, and they are evenly distributed (i.e. all number have the same probability). Calvin thx!!! :-D:omg::rolleyes:

    J M 2 Replies Last reply
    0
    • W wong1907

      Hello, I want to ask how to generate a random number which is lie between 0 and n, and they are evenly distributed (i.e. all number have the same probability). Calvin thx!!! :-D:omg::rolleyes:

      J Offline
      J Offline
      jmkhael
      wrote on last edited by
      #2

      Why dont u use : srand ( time ( NULL ) ) ; int RandomNumber = rand () % (n + 1) ; Papa while (TRUE) Papa.WillLove ( Bebe ) ;

      L 1 Reply Last reply
      0
      • J jmkhael

        Why dont u use : srand ( time ( NULL ) ) ; int RandomNumber = rand () % (n + 1) ; Papa while (TRUE) Papa.WillLove ( Bebe ) ;

        L Offline
        L Offline
        Le centriste
        wrote on last edited by
        #3

        oops, misread the question. Michel It is a lovely language, but it takes a very long time to say anything in it, because we do not say anything in it, unless it is worth taking a very long time to say, and to listen to.
        - TreeBeard

        1 Reply Last reply
        0
        • W wong1907

          Hello, I want to ask how to generate a random number which is lie between 0 and n, and they are evenly distributed (i.e. all number have the same probability). Calvin thx!!! :-D:omg::rolleyes:

          M Offline
          M Offline
          Mike Nordell
          wrote on last edited by
          #4

          For a reasonably good random number generator you might want to have a look at the source for dev/random from the Linux sources (rand() from e.g the MS CRT will get you nowhere near randomness).

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups