C++ Challenge - Randomization 11-03-2013, 09:17 PM
#1
Objective: Create a condition assignable to a boolean variable, using a random generated number.
Constraints:
1. No use of division or modulus operations by any means
2. Can only use one call to a random generator function
3. No other hardcoded values, the only value you can use is the one generated by the random method itself, and the only other variable in your program should be a single boolean variable
4. Booleans true/false formed by values 0 or 1 are not allowed either from the randomly generated value
5. (No inline ASM)
Constraints:
1. No use of division or modulus operations by any means
2. Can only use one call to a random generator function
3. No other hardcoded values, the only value you can use is the one generated by the random method itself, and the only other variable in your program should be a single boolean variable
4. Booleans true/false formed by values 0 or 1 are not allowed either from the randomly generated value
5. (No inline ASM)
Code:
#include <iostream>
#include <cstdlib>
#include <ctime>
int main()
{
srand(time(0));
short/int/etc... r = { random generated value };
bool b = ___________;
std::cout << (b ? "TRUE" : "FALSE") << std::endl;
}
ArkPhaze
"Object oriented way to get rich? Inheritance"
Getting Started: C/C++ | Common Mistakes
[ Assembly / C++ / .NET / Haskell / J Programmer ]
"Object oriented way to get rich? Inheritance"
Getting Started: C/C++ | Common Mistakes
[ Assembly / C++ / .NET / Haskell / J Programmer ]


![[+]](https://sinister.li/images/modern/collapse_collapsed.png)
