This page contains affiliate links. We may earn commissions when readers interact with or purchase items through these links. For more information, see our affiliate disclosures here.

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 2: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 9:36 am

Postby Predaprince » Sat Mar 17, 2007 5: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 7: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 5: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 3: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 9: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 3: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 11:15 am

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 1: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 11:56 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
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 3: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 6: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 9:36 am


Return to General Discussion

Registered users: Bing [Bot], Google [Bot], Majestic-12 [Bot]

Transformers and More @ The Seibertron Store

Visit our store on eBay
These are affiliate links. We may earn commissions when you purchase items or services through these links.
Visit shop.seibertron.com to buy "GI JOE Real American Hero #308 Cvr B Image Comics 0524IM301 308B (CA) Kubert"
GI JOE Real Americ ...
Visit shop.seibertron.com to buy "THE TRANSFORMERS #1 40th Anniversary Cvr A Image Comics 2024 Skybound 01A"
NEW!
THE TRANSFORMERS # ...
Visit shop.seibertron.com to buy "THE TRANSFORMERS #1 40th Anniversary Cvr B Image Comics 2024 Skybound 01B Ward"
NEW!
THE TRANSFORMERS # ...
Visit shop.seibertron.com to buy "GI JOE Real American Hero #310 1:10 Cvr C Image Comics 0624IM299 310C (CA)Walker"
NEW!
GI JOE Real Americ ...
Visit shop.seibertron.com to buy "GI JOE AND THE TRANSFORMERS #1 Marvel Comics 1987 (CA) Trimpe 240607A"
GI JOE AND THE TRA ...
Visit shop.seibertron.com to buy "THE TRANSFORMERS #1 40th Anniversary Cvr C Image Comics 2024 Skybound 01C Blank"
NEW!
THE TRANSFORMERS # ...
Visit shop.seibertron.com to buy "GI JOE Real American Hero #309 Cvr A Image Comics 0624IM297 309A (CA) Kubert"
NEW!
GI JOE Real Americ ...
Visit shop.seibertron.com to buy "GI JOE Real American Hero #301 Cvr A CGC 9.8 Image Comics 2023 301A (CA) Kubert"
GI JOE Real Americ ...
Visit shop.seibertron.com to buy "GI JOE Real American Hero #308 Cvr A Image Comics 0524IM300 308A (CA) Kubert"
GI JOE Real Americ ...
Visit shop.seibertron.com to buy "GI JOE Real American Hero #308 Cvr C 1:10 Image Comics 2024 0524IM302 308C"
GI JOE Real Americ ...
Visit shop.seibertron.com to buy "GI JOE Real American Hero #302 Cvr A Image Comics 302A 1023IM317 Kubert 240731D"
NEW!
GI JOE Real Americ ...
Visit shop.seibertron.com to buy "GI JOE AND THE TRANSFORMERS #1 Marvel Comics 1987 (CA) Trimpe 240607C"
GI JOE AND THE TRA ...
Visit shop.seibertron.com to buy "GI JOE Real American Hero #309 Cvr B Image Comics 0624IM298 309B (CA) Kubert"
NEW!
GI JOE Real Americ ...
Visit shop.seibertron.com to buy "GI JOE Real American Hero #302 Cvr A Image Comics 302A 1023IM317 Kubert 240731E"
NEW!
GI JOE Real Americ ...
* Price and quantities subject to change. Shipping costs, taxes and other fees not included in cost shown. Refer to listing for current price and availability.
Find the items above and thousands more at the Seibertron Store on eBay
Transformers Podcast: Twincast / Podcast #358 - Size Wars
Twincast / Podcast #358:
"Size Wars"
MP3 · iTunes · RSS · View · Discuss · Ask
Posted: Saturday, September 7th, 2024

Featured Products on Amazon.com

These are affiliate links. We may earn commissions when you purchase items or services through these links.
Buy "Transformers Generations Exclusive Cyber Battalion Class Shockwave Figure" on AMAZON
Buy "Transformers MPM-03 Movie 10th Anniversary Figure Bumblebee" on AMAZON
Buy "Transformers: Bumblebee Movie Toys, Power Charge Bumblebee Action Figure - Spinning Core, Lights and Sounds - Toys for Kids 6 and Up, 10.5-inch" on AMAZON
Buy "Transformers Studio Series 09 Voyager Class Movie 2 Thundercracker" on AMAZON
Buy "Transformers Generations Titans Return Deluxe Twin Twist and Flameout" on AMAZON
Buy "Transformers: Generations Power of The Primes Legends Class Autobot Outback" on AMAZON
Buy "Masterpiece MPM-7 Bumblebee" on AMAZON
Buy "Cyberverse Warrior Class Acid Storm" on AMAZON
Buy "Transformers Generations Combiner Wars Voyager Class Onslaught Figure" on AMAZON
Buy "Transformers: Generations Power of The Primes Vector Prime Prime Master" on AMAZON
Buy "Transformers: The Last Knight Premier Edition Voyager Class Megatron" on AMAZON
Buy "Transformers Generations Titans Return Autobot Blaster and Twin Cast (Discontinued by manufacturer)" on AMAZON