![]() |
|
|
|
#1 |
|
I have this short program. And I think I've asked something similar
before but I want random up to 12 numbers here representing a dice. #include <stdio.h> #include <stdlib.h> #include <time.h> int main(void) { srand(time(NULL)); printf("%i\n", rand()); } This is great at getting seemingly real random numbers but they're huge numbers. Can use this randomness to get a number from 1-12? 1-16 and so on? Bill Bill Cunningham |
|
|
|
|
#2 |
|
Posts: n/a
|
"Bill Cunningham" <> writes:
> I have this short program. And I think I've asked something similar > before but I want random up to 12 numbers here representing a dice. > > #include <stdio.h> > #include <stdlib.h> > #include <time.h> > > int main(void) > { > srand(time(NULL)); > printf("%i\n", rand()); > } > > This is great at getting seemingly real random numbers but they're huge > numbers. Can use this randomness to get a number from 1-12? 1-16 and so on? comp.lang.c FAQ, question 13.16. -- Keith Thompson (The_Other_Keith) kst- <http://www.ghoti.net/~kst> Nokia "We must do something. This is something. Therefore, we must do this." -- Antony Jay and Jonathan Lynn, "Yes Minister" Keith Thompson |
|
|
|
#3 |
|
Posts: n/a
|
On 06 Nov 2009, "Bill Cunningham" <> wrote:
> I have this short program. And I think I've asked something > similar > before but I want random up to 12 numbers here representing a > dice. > > #include <stdio.h> > #include <stdlib.h> > #include <time.h> > > int main(void) > { > srand(time(NULL)); > printf("%i\n", rand()); > } > > This is great at getting seemingly real random numbers but > they're huge > numbers. Can use this randomness to get a number from 1-12? 1-16 > and so on? > > Bill Take a look at Q13.16 in the C FAQ <http://www.c-faq.com>. -- Don't worry about efficiency until you've attained correctness. ~ Eric Sosman Curtis Dyer |
|
|
|
#4 |
|
Posts: n/a
|
On 2009-11-07, Richard <rgrdev_@gmail.com> wrote:
> It is impossible to do this in C as you have discovered with your > extensive research Bill. I suggest that for complex mathematical > problems like this that you look into using Haskell. It's really > easy. Honest. And you bitch about other people giving people bad answers or being dismissive of them? -s p.s.: To be fair, either Bill is a stellar troll or there really isn't much point, but it still seems a bit silly to do this and complain that other people do it. -- Copyright 2009, all wrongs reversed. Peter Seebach / usenet- http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated! Seebs |
|
|
|
#5 |
|
Posts: n/a
|
"Keith Thompson" <kst-> wrote in message news:... > comp.lang.c FAQ, question 13.16. Thanks. I will try this and see if it works. Bill Bill Cunningham |
|
|
|
#6 |
|
Posts: n/a
|
In article <Gu- ca>,
Gordon Burditt <> wrote: >>There is no point in attaining "correctness" in a dog of a program which >>needs to be totally replumbed to achieve the desired level of >>efficiency. > >If the program doesn't have to be correct, it can run in 0 bytes for 0 time. > There is a difference - a big huge, honking difference - between being correct (without the quotes) and posessing "correctness" (in the CLC sense, and with the quotes). In CLC, "correctness" is analogous to "truthiness". Note that many of the CLC stalwarts are crypto-Bushies. Kenny McCormack |
|