1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
|
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <random>
using namespace std;
int main() {
srand((unsigned) time(0));
float RN1, RN2, RN3, RN4, totSTR; //Each of these values is created...
for (int index = 0; index < 1; index++) {
RN1 = (rand() % 6) + 1;
RN2 = (rand() % 6) + 1;
RN3 = (rand() % 6) + 1;
RN4 = (rand() % 6) + 1;
int lowest;
lowest = NULL;
if (RN1 < RN2, RN3, RN4) RN1 = lowest; //...and are sorted for the lowest here.
else if (RN2 < RN1, RN3, RN4) RN2 = lowest;
else if (RN3 < RN1, RN2, RN4) RN3 = lowest;
else if (RN4 < RN1, RN2, RN3) RN4 = lowest;
totSTR = RN1 + RN2 + RN3 + RN4; //Here, the four values, and the lowest which is now 0, are added...
cout << "Your Strength is: " << totSTR << endl;//and displayed here...
srand((unsigned)time(0)); //Here, I've repeated the previous code with a separate set of float values.
float RN5, RN6, RN7, RN8, totDEX;//I figured that by setting up a new set of values altogether, they'd generate differently.
for (int index = 0; index < 1; index++) {
RN5 = (rand() % 6) + 1;
RN6 = (rand() % 6) + 1;
RN7 = (rand() % 6) + 1;
RN8 = (rand() % 6) + 1;
int lowest2;
lowest2 = NULL;
if (RN5 < RN6, RN7, RN8) RN5 = lowest2;//They're executed in a repeat of the same code, but being a different set of values, and that includes another int lowest.
else if (RN6 < RN5, RN7, RN8) RN6 = lowest2;
else if (RN7 < RN5, RN6, RN8) RN7 = lowest2;
else if (RN5 < RN6, RN6, RN7) RN8 = lowest2;
totDEX = RN5 + RN6 + RN7 + RN8;
cout << "Your Dexterity is: " << totDEX << endl; //However, it displays the same number as the four different values above. This says that they're creating the exact same number values (RN1 always = RN5).
}
}
}
//But how?
|