Login Register






C++ Challenge - Randomization filter_list
Author
Message
C++ Challenge - Randomization #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)

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 ]

Reply





Messages In This Thread
C++ Challenge - Randomization - by ArkPhaze - 11-03-2013, 09:17 PM