>
shop.seibertron.com amazon.seibertron.com Facebook Twitter X YouTube Pinterest Instagram Myspace LinkedIn Patreon Podcast RSS
This page runs on affiliate links — your clicks may earn us a few Shanix. Want the full transmission? Roll out to our Affiliate Disclosure.

help with c++

Welcome to the General Discussion area where just about anything goes! This area is designed to discuss all matters and does not necessarily have to be Transformers related. Please keep topics relevant.

help with c++

Postby tequila stu » Sat Mar 17, 2007 3:53 am

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: Select all
    {
    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");

        }
tequila stu
Pretender
Posts: 728
Joined: Thu Feb 24, 2005 10:36 am

Postby Predaprince » Sat Mar 17, 2007 6:54 am

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.
User avatar
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

Postby Stormwolf » Sat Mar 17, 2007 6:57 am

Weapon: Particle Beam Cannon
I haven't used C++ in over 4 years, I can't remember a thing about it, sorry :-(
Image
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++

Postby The Happy Locust » Sat Mar 17, 2007 10:41 am

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: Select all
for(float index=0; index<8; index++){
        rw1 = lowest+float(range*rand()/(RAND_MAX + 100));


updated code
Code: Select all
for (float index=0; index<8; index++){
    randomArray[index] = lowest+float(range*rande()/RAND_MAX + 100);


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.
Image


LocustManX2: New Episodes now showing!
Famous Characters, Locustized! now taking requests.

Psycho Warrior wrote:for this reason, that is why I like to be around Locust. fun stuff happens.
User avatar
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

Postby Bed Bugs » Sat Mar 17, 2007 12:15 pm

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. :lol:
Image
Botcon: The Legacy Collection
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+

Postby The Happy Locust » Sat Mar 17, 2007 12:56 pm

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
Fender Bender wrote: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. :lol:


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.
Image


LocustManX2: New Episodes now showing!
Famous Characters, Locustized! now taking requests.

Psycho Warrior wrote:for this reason, that is why I like to be around Locust. fun stuff happens.
User avatar
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++

Postby tequila stu » Sat Mar 17, 2007 7:34 pm

The Happy Locust wrote: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: Select all
for(float index=0; index<8; index++){
        rw1 = lowest+float(range*rand()/(RAND_MAX + 100));


updated code
Code: Select all
for (float index=0; index<8; index++){
    randomArray[index] = lowest+float(range*rande()/RAND_MAX + 100);


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


Return to General Discussion


[ Incoming message. Source unknown. ] No Signal - Please Stand By [ Click to attempt signal recovery... ]


Transformers and More @ The Seibertron Store

Visit shop.seibertron.com to buy "Star Wars MANDALORIAN #7 Marvel Comics 2023 OCT221182 (CA) McNiven (W) Barnes"
NEW!
Star Wars MANDALOR ...
Visit shop.seibertron.com to buy "SHE-HULK #10 var Marvel Comics 2023 OCT221161 (CA) Talaski (W) Rowell"
NEW!
SHE-HULK #10 var M ...
Visit shop.seibertron.com to buy "X-MEN LEGENDS #11 Marvel Comics 2022 NOV210886 (W) Simonson (A/CA) Simonson"
NEW!
X-MEN LEGENDS #11 ...
Visit shop.seibertron.com to buy "DEADPOOL KILLS MARVEL UNIVERSE #1 Facsimile Marvel Comics 2024 ptg APR240569"
NEW!
DEADPOOL KILLS MAR ...
Visit shop.seibertron.com to buy "Star Wars JABBAS PALACE #1 Marvel Comics 2023 DEC220908 (CA) Brown (W)Guggenheim"
Star Wars JABBAS P ...
Visit shop.seibertron.com to buy "2099 OMEGA #1 Marvel Comics 2019 OCT190942 (W) Spencer (A) Sandoval (CA) Gleason"
NEW!
2099 OMEGA #1 Marv ...
Visit shop.seibertron.com to buy "Star Wars MANDALORIAN #8 Marvel Comics 2023 DEC220804 (CA) Pichelli (W) Barnes"
NEW!
Star Wars MANDALOR ...
Visit shop.seibertron.com to buy "Star Wars MANDALORIAN #6 Marvel Comics 2022 OCT220992 (CA) Gleason (W) Barnes"
NEW!
Star Wars MANDALOR ...
Visit shop.seibertron.com to buy "X-FORCE #27 var Promo Marvel Comics 2022 FEB220949 (W) Percy (CA) Weaver (A)Gill"
X-FORCE #27 var Pr ...
Visit shop.seibertron.com to buy "Demon Days BLOOD FEUD #1 var Marvel Comics 2022 JAN220843 (CA) Barends"
NEW!
Demon Days BLOOD F ...
Visit shop.seibertron.com to buy "X-MEN AGE OF REVELATION #0 Shadow Drop Variant Marvel Comics 2025 (CA) Ramos"
NEW!
X-MEN AGE OF REVEL ...
Visit shop.seibertron.com to buy "FANTASTIC FOUR #2 Facsimile Foil Marvel Comics 2025 ptg NOV240859 (CA) Kirby"
NEW!
FANTASTIC FOUR #2 ...
Visit shop.seibertron.com to buy "ALIEN #1 var 1:25 Marvel Comics 2021 JAN210573 (A/CA) Larroca (W) Johnson"
NEW!
ALIEN #1 var 1:25 ...
Visit shop.seibertron.com to buy "Star Wars War Bounty Hunters ALPHA #1 var crimson Marvel Comics 2021 MAR210655"
Star Wars War Boun ...
These are affiliate links. We may earn a commission.
Details subject to change. See listing for latest price and availability.

Featured Products on Amazon.com

Buy "Transformers Generations Exclusive Cyber Battalion Class Shockwave Figure" on AMAZON
Buy "Transformers Titans Return Arcee Action Figure Set" on AMAZON
Buy "Transformers: Generations Power of The Primes Legends Class Autobot Tailgate" on AMAZON
Buy "Transformers Deluxe 20 Mercenary Action Figure" on AMAZON
Buy "Transformers Toys Megatron Cyberverse Ultimate Class Action Figure - Repeatable Fusion Mega Shot Action Attack Move - Toys for Kids 6 and Up, 11.5-inch" on AMAZON
Buy "Transformers Studio Series 11 Deluxe Class Movie 4 Lockdown" on AMAZON
Buy "Transformers Studio Series 09 Voyager Class Movie 2 Thundercracker" on AMAZON
Buy "Transformers: Generations Power of The Primes Megatronus Prime Master" on AMAZON
Buy "Transformers Generations, Platinum Edition, One Shall Stand, One Shall Fall" on AMAZON
Buy "Hasbro Transformers Generations Titans Return Soundwave and Soundblaster" on AMAZON
Buy "Transformers Generations Titans Return Autobot Infinitus and Sentinel Prime" on AMAZON
Buy "Transformers: Generations Titans Return Legends Class Seaspray" on AMAZON
These are affiliate links. We may earn a commission.
Details subject to change. See listing for latest price and availability.