|
From: <Gen...@ao...> - 2001-02-13 16:26:13
|
check out: 1. rand() <-- value up to RAND_MAX 2. random(ceiling) <-- probably the one you want.. 3. randomize() - <-- to seed 4. srand(seed) <-- to initialize Gene |
|
From: Jose F. <jf...@ax...> - 2001-02-13 16:57:51
|
I get and error " implicit declaration of function 'int random(....)' " when I tried the "number = random(13)+1;" command. Any suggestions? -----Original Message----- From: Jesper [mailto:hag...@ho...] Sent: Tuesday, February 13, 2001 11:29 AM To: dev...@li... Subject: Re: [Dev-C++] Random Number Try this it might work: number = random(13)+1; Jesper ----- Original Message ----- From: "Jose Flores" <jf...@ax...> To: <dev...@li...> Sent: Tuesday, February 13, 2001 5:16 PM Subject: [Dev-C++] Random Number > what is a good simple command to get a random number from 1 to 13? I keep > getting the run around when I ask this question... > Thanks > Jose > > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > http://lists.sourceforge.net/lists/listinfo/dev-cpp-users > _______________________________________________ Dev-cpp-users mailing list Dev...@li... http://lists.sourceforge.net/lists/listinfo/dev-cpp-users |
|
From: Jesper <hag...@ho...> - 2001-02-13 17:08:27
|
You must include stdlib.h. like this: #include <iostream.h> #include <stdlib.h> Hope this solve the problem. Jesper ----- Original Message -----=20 From: "Jose Flores" <jf...@ax...> To: <dev...@li...> Sent: Tuesday, February 13, 2001 5:58 PM Subject: RE: [Dev-C++] Random Number > I get and error " implicit declaration of function 'int = random(....)' " > when I tried the "number =3D random(13)+1;" command. Any suggestions? >=20 > -----Original Message----- > From: Jesper [mailto:hag...@ho...] > Sent: Tuesday, February 13, 2001 11:29 AM > To: dev...@li... > Subject: Re: [Dev-C++] Random Number >=20 >=20 > Try this it might work: >=20 > number =3D random(13)+1; >=20 > Jesper >=20 > ----- Original Message -----=20 > From: "Jose Flores" <jf...@ax...> > To: <dev...@li...> > Sent: Tuesday, February 13, 2001 5:16 PM > Subject: [Dev-C++] Random Number >=20 >=20 > > what is a good simple command to get a random number from 1 to 13? = I keep > > getting the run around when I ask this question... > > Thanks=20 > > Jose > >=20 > > _______________________________________________ > > Dev-cpp-users mailing list > > Dev...@li... > > http://lists.sourceforge.net/lists/listinfo/dev-cpp-users > >=20 >=20 >=20 > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > http://lists.sourceforge.net/lists/listinfo/dev-cpp-users >=20 > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > http://lists.sourceforge.net/lists/listinfo/dev-cpp-users >=20 |
|
From: Jesper <hag...@ho...> - 2001-02-13 20:40:39
|
//beginning of program
#include <iostream.h>
#include <stdlib.h>
int main()
{
int number;
number=3D1+rand()%13;
cout << number;
return 0;
}
//end of program
Try this it worked. One stupid thing is that it gives you the same =
number everytime you use it.I have forgotten how to do if you want =
diffrent numbers every time you use the program.
Anyone knows?
Jesper
----- Original Message -----=20
From: "Jose Flores" <jf...@ax...>
To: <dev...@li...>
Sent: Tuesday, February 13, 2001 5:58 PM
Subject: RE: [Dev-C++] Random Number
> I get and error " implicit declaration of function 'int =
random(....)' "
> when I tried the "number =3D random(13)+1;" command. Any suggestions?
>=20
> -----Original Message-----
> From: Jesper [mailto:hag...@ho...]
> Sent: Tuesday, February 13, 2001 11:29 AM
> To: dev...@li...
> Subject: Re: [Dev-C++] Random Number
>=20
>=20
> Try this it might work:
>=20
> number =3D random(13)+1;
>=20
> Jesper
>=20
> ----- Original Message -----=20
> From: "Jose Flores" <jf...@ax...>
> To: <dev...@li...>
> Sent: Tuesday, February 13, 2001 5:16 PM
> Subject: [Dev-C++] Random Number
>=20
>=20
> > what is a good simple command to get a random number from 1 to 13? =
I keep
> > getting the run around when I ask this question...
> > Thanks=20
> > Jose
> >=20
> > _______________________________________________
> > Dev-cpp-users mailing list
> > Dev...@li...
> > http://lists.sourceforge.net/lists/listinfo/dev-cpp-users
> >=20
>=20
>=20
> _______________________________________________
> Dev-cpp-users mailing list
> Dev...@li...
> http://lists.sourceforge.net/lists/listinfo/dev-cpp-users
>=20
> _______________________________________________
> Dev-cpp-users mailing list
> Dev...@li...
> http://lists.sourceforge.net/lists/listinfo/dev-cpp-users
>=20
|
|
From: Jesper <hag...@ho...> - 2001-02-14 09:57:16
|
//New random numder every time you run it
#include <iostream.h>
#include <stdlib.h>
#include <time.h>
int main()
{
int number;
srand (time(0));
number=3D1+rand()%13;
cout << number;
return 0;
}
//End of the program
I have just tested this program and it works and gives you new number =
every time.
Jesper
|
|
From: Robert D B. <lon...@ju...> - 2001-02-13 18:17:08
|
Try this: #include <cstdlib> #include <ctime> using std::srand; using std::rand; num = rand()/(RAND_MAX/12); // 0-12 num++; // to eliminate zero. you can add the ++ to the above num = Regards, lstar36 On Tue, 13 Feb 2001 11:16:44 -0500 Jose Flores <jf...@ax...> writes: > what is a good simple command to get a random number from 1 to 13? I > keep > getting the run around when I ask this question... > Thanks > Jose > > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > http://lists.sourceforge.net/lists/listinfo/dev-cpp-users > |
|
From: <Gen...@ao...> - 2001-02-13 20:05:14
|
In a message dated 2/13/01 9:00:11 AM Pacific Standard Time, jf...@ax... writes: > I get and error " implicit declaration of function 'int random(....)' " > when I tried the "number = random(13)+1;" command. Any suggestions? > > try #include <stdlib.h> If that doesn't work, ask Colin where the prototype for random() is.. |
|
From: Robert D B. <lon...@ju...> - 2001-02-13 20:20:29
|
there is no random() function in dec-c++. Use Ran() lstar36 On Tue, 13 Feb 2001 15:05:18 EST Gen...@ao... writes: In a message dated 2/13/01 9:00:11 AM Pacific Standard Time, jf...@ax... writes: I get and error " implicit declaration of function 'int random(....)' " when I tried the "number = random(13)+1;" command. Any suggestions? try #include <stdlib.h> If that doesn't work, ask Colin where the prototype for random() is.. |
|
From: <Gen...@ao...> - 2001-02-13 20:56:10
|
In a message dated 2/13/01 12:43:39 PM Pacific Standard Time,
hag...@ho... writes:
> #include <stdlib.h>
>
> int main()
> {
> int number;
> number=1+rand()%13;
> cout << number;
> return 0;
> }
> //end of program
>
> Try this it worked. One stupid thing is that it gives you the same number
> everytime you use it.I have forgotten how to do if you want diffrent
> numbers every time you use the program.
>
>
srand() should do it... You need to 'seed' the random number generator with
some random value.
|
|
From: <Gen...@ao...> - 2001-02-13 20:56:20
|
"C" and/or "C++" according to my Programmers Bible.. Gene |
|
From: Ioannis V. <no...@ya...> - 2001-02-13 20:50:30
|
random(), randomize() belong to what language? Ioannis * Ioannis Vranos * Programming pages: http://members.nbci.com/noicys * Alternative URL: http://run.to/noicys -----Original Message----- From: dev...@li... [mailto:dev...@li...]On Behalf Of Gen...@ao... Sent: Tuesday, February 13, 2001 6:27 PM To: dev...@li... Subject: Re: [Dev-C++] Random Number check out: 1. rand() <-- value up to RAND_MAX 2. random(ceiling) <-- probably the one you want.. 3. randomize() - <-- to seed 4. srand(seed) <-- to initialize Gene |