Feb 25, 2015 at 5:06pm UTC
Last edited on Feb 25, 2015 at 7:15pm UTC
Feb 25, 2015 at 6:21pm UTC
I have no idea what you want us to answer here. The code that you provided currently does nothing at all. Did you try and loop it? Can you show us how you tried?
Feb 25, 2015 at 6:36pm UTC
As it stands, it does nothing. It's 500+ lines of code. :P
This is just the first variable. I'll post a little more, but I'm trying to figure out why the random is spitting out the same number when I looped it.
Also, sorry, I put the wrong code above. This is the one where I actually tried to loop it.
#include <tchar.h>
#define _tWinMain wWinMain
#include <iostream>
#include <ctime>
#include <string>
using namespace std;
int _tmain()
{
int number;
srand(time(NULL));
double random;
float time;
random = (rand() % (100) + 1);
double gold;
gold = (random * 5);
double d10;
double d102;
double weapon;
weapon = (rand() % (10) + 1);
d10 = (rand() % (10) + 1);
d102 = (rand() % (10) + 1);
bool formal = "";
double quartz;
double quartz2;
double quartz3;
double insect;
double oak;
double fault;
double dragon;
double scales;
double cactus;
double blooms;
double moredust;
double moreshell;
double morescales;
double moreblooms;
double ruby;
double silver;
double hide;
double enchant;
double enchant2;
quartz = (rand() % ((10) + 1)*5);
quartz2 = (rand() % (10 + 1)*10);
quartz3 = (rand() % (10 + 1)*20);
insect = (rand() % (10) + 1);
oak = (rand() % (10 + 1))/2;
fault = (rand() % (10 + 1)/3);
dragon = (rand() % (10 + 1)/5);
scales = (rand() % (10 + 1));
cactus = (rand() % (10 + 1));
blooms = (rand() % (10 + 1) *2);
moredust = (rand() % (10 + 1)/2);
moreshell = (rand() % (10 + 1)/3);
moreblooms = (rand() % (10 + 1)*3);
ruby = (rand() % ((10) + 1))/5;
silver = (rand() % (10 + 1)/5);
hide = (rand() % ((10) + 1)/5);
enchant = (rand() % (10 + 1) / 3);
enchant2 = (rand() % (10 + 1) / 2);
morescales = (rand() % (10 + 1) * 2);
cout << "How many times are we rolling today?";
std::cin >> number;
for (int x = 0; x < number; x++)
{
Feb 25, 2015 at 6:51pm UTC
I dont see a loop anywhere in your code. Also, Im not sure what this is int _tmain()
Should be int main.
Feb 25, 2015 at 6:54pm UTC
At the very bottom is where the loop starts. It loops a number of times equal to user input of "number".
Feb 25, 2015 at 6:55pm UTC
Again, I can't put the full code on here, unless you want me to put it piecemeal, because it's very, very long.
Feb 25, 2015 at 7:07pm UTC
put your code on www.pastebin.com and post the link by editing your first post.
Feb 25, 2015 at 7:13pm UTC
Sorry I completely missunderstood your question. I know what you mean now. uhm...
Could you tell me in words what you want this piece of code to do - enchant = (rand() % (10 + 1) / 3);
Feb 25, 2015 at 7:20pm UTC
...Now I'm embarrassed. Can't believe I forgot something so fooking basic. :(
I'll fix it and get back to ya with the result in a bit.
Feb 25, 2015 at 8:00pm UTC
I see. The value of "random" Never changes, because it is initialized outside of the loop.
Move these -
1 2
random = (rand() % (100) + 1);
gold = (random * 5);
And put them at the top of the for-loop -
1 2 3 4 5 6 7 8
for (int x = 0; x < number; x++)
{
random = (rand() % (100) + 1);
gold = (random * 5);
cout << "You rolled " << random << endl;
if (random >= 1 & random <= 20)
That will fix it :)
Also please change it to
int main()
and not
int _tmain()
Last edited on Feb 25, 2015 at 8:01pm UTC
Feb 25, 2015 at 8:22pm UTC
You're a wizard.
Thank you! I've been struggling with this problem for a bit.
Feb 25, 2015 at 8:27pm UTC
You're very welcome. Please next time only post in one forum section :) goodluck to you.