Hey, I am just wondering if anyone on here knows c++.
I have got a piece of coursework to do for the 10th of April that requires a random number generator and the ability to save and re-call the numbers. now as I have never used a R.N.G before I am absolutely stumped. I can get it to generate the numbers but can't quite seem to figure out how to store them.
Any help is appreciated.
*edit*
almost forgot, this is the generator I am using.
[code] {
srand((unsigned)time(0));
float lowest=-10, highest=10;
float range=(highest-lowest)+1;
for(float index=0; index<8; index++){
rw1 = lowest+float(range*rand()/(RAND_MAX + 100));
cout << setprecision(2) << setiosflags(ios::fixed);
cout << endl;
system ("pause");
}[/code]
help with c++
7 posts
• Page 1 of 1
- Motto: ""Destruction is the fate of all sentient beings.""
- Weapon: Sonic Rifle
I wish I could help, but I don't know much of C++. I use Python for most of my programming.
Good luck with it, though.
Good luck with it, though.
-

Predaprince - God Of Transformers
- Posts: 15225
- Joined: Mon May 23, 2005 8:33 am
- Location: Char
- Strength: 9
- Intelligence: 9
- Speed: 7
- Endurance: 9
- Rank: N/A
- Courage: 10
- Firepower: ???
- Skill: Infinity
- Weapon: Particle Beam Cannon
I haven't used C++ in over 4 years, I can't remember a thing about it, sorry
- Stormwolf
- Brainmaster
- Posts: 1280
- News Credits: 3
- Joined: Thu Jun 26, 2003 4:39 pm
- Strength: 10
- Intelligence: 10
- Speed: 10
- Endurance: 10
- Rank: 10
- Courage: 10
- Firepower: 10
- Skill: 10
Re: help with c++
- Motto: "A common mistake that people make when trying to design something completely foolproof is to underestimate the ingenuity of complete fools- Douglas Adams"
- Weapon: Black Magic
funny, looks like that code isn't printing anything.
Okay, the easiest way to store the random numbers is either in an array or a linked list.
the current code:
[code]
for(float index=0; index<8; index++){
rw1 = lowest+float(range*rand()/(RAND_MAX + 100)); [/code]
updated code
[code]
for (float index=0; index<8; index++){
randomArray[index] = lowest+float(range*rande()/RAND_MAX + 100);
[/code]
just make an array of whatever number of objects you need and save the random number directly to it. Obviously, you need to create the array first. hope that helps.
Okay, the easiest way to store the random numbers is either in an array or a linked list.
the current code:
[code]
for(float index=0; index<8; index++){
rw1 = lowest+float(range*rand()/(RAND_MAX + 100)); [/code]
updated code
[code]
for (float index=0; index<8; index++){
randomArray[index] = lowest+float(range*rande()/RAND_MAX + 100);
[/code]
just make an array of whatever number of objects you need and save the random number directly to it. Obviously, you need to create the array first. hope that helps.
Next up on Pimp My Jeager.

LocustManX2: New Episodes now showing!
Famous Characters, Locustized! now taking requests.
[quote="Psycho Warrior"]for this reason, that is why I like to be around Locust. fun stuff happens.

LocustManX2: New Episodes now showing!
Famous Characters, Locustized! now taking requests.
[quote="Psycho Warrior"]for this reason, that is why I like to be around Locust. fun stuff happens.
-

The Happy Locust - Guardian Of Seibertron
- Posts: 5503
- Joined: Sun Sep 29, 2002 4:46 pm
- Location: In dreams, in nightmares, in embarrassing fantasies.
- Strength: 3
- Intelligence: 8
- Speed: 9
- Endurance: 3
- Rank: 1
- Courage: 2
- Firepower: 3
- Skill: 10
- Motto: "The Bigger The Buffet, The Better!"
- Weapon: Black Magic
Damn, I learned C++ and Java a year and a half ago and forgot most of it. Hence why I'm not a programmer anymore.
[center]
Botcon: The Legacy Collection[/center]

Botcon: The Legacy Collection[/center]
- Bed Bugs
- Gestalt
- Posts: 2951
- News Credits: 349
- Joined: Tue Apr 29, 2003 2:08 pm
- Location: Under Your Bed at Botcon
- Alt Mode: A Bed Bug
- Strength: 10+
- Intelligence: 10+
- Speed: 10+
- Endurance: 10+
- Rank: 10+
- Courage: 10+
- Firepower: 10+
- Skill: 10+
- Motto: "A common mistake that people make when trying to design something completely foolproof is to underestimate the ingenuity of complete fools- Douglas Adams"
- Weapon: Black Magic
[quote="Fender Bender"]Damn, I learned C++ and Java a year and a half ago and forgot most of it. Hence why I'm not a programmer anymore. 
Don't feel bad. I've got a degree and I still had to look up my old homework to remember that.
Next up on Pimp My Jeager.

LocustManX2: New Episodes now showing!
Famous Characters, Locustized! now taking requests.
[quote="Psycho Warrior"]for this reason, that is why I like to be around Locust. fun stuff happens.

LocustManX2: New Episodes now showing!
Famous Characters, Locustized! now taking requests.
[quote="Psycho Warrior"]for this reason, that is why I like to be around Locust. fun stuff happens.
-

The Happy Locust - Guardian Of Seibertron
- Posts: 5503
- Joined: Sun Sep 29, 2002 4:46 pm
- Location: In dreams, in nightmares, in embarrassing fantasies.
- Strength: 3
- Intelligence: 8
- Speed: 9
- Endurance: 3
- Rank: 1
- Courage: 2
- Firepower: 3
- Skill: 10
Re: help with c++
[quote="The Happy Locust"]funny, looks like that code isn't printing anything.
Okay, the easiest way to store the random numbers is either in an array or a linked list.
the current code:
[code]
for(float index=0; index<8; index++){
rw1 = lowest+float(range*rand()/(RAND_MAX + 100)); [/code]
updated code
[code]
for (float index=0; index<8; index++){
randomArray[index] = lowest+float(range*rande()/RAND_MAX + 100);
[/code]
just make an array of whatever number of objects you need and save the random number directly to it. Obviously, you need to create the array first. hope that helps.
Okay, the easiest way to store the random numbers is either in an array or a linked list.
the current code:
[code]
for(float index=0; index<8; index++){
rw1 = lowest+float(range*rand()/(RAND_MAX + 100)); [/code]
updated code
[code]
for (float index=0; index<8; index++){
randomArray[index] = lowest+float(range*rande()/RAND_MAX + 100);
[/code]
just make an array of whatever number of objects you need and save the random number directly to it. Obviously, you need to create the array first. hope that helps.
yeah...i just realised i forgot to paste in the part that shows the numbers..
thanks for the help man....much appreciated.
- tequila stu
- Pretender
- Posts: 728
- Joined: Thu Feb 24, 2005 10:36 am
7 posts
• Page 1 of 1
Who is online
Registered users: Apple [Bot], Bing [Bot], Bumblevivisector, ChatGPT [Bot], demoman0121, DuckDuckGo [Bot], Glyph, Google [Bot], Google Adsense [Bot], Google Feedfetcher, Hero Alpha, MSN [Bot], OpenAI [Bot], Overcracker, Transbot, Yahoo [Bot], Yandex [Bot]

