how to rand between three integer num1 num2 num 3
fadi_1234
-3
Light Poster
Recommended Answers
Jump to PostYou want a random selection. There are a few ways, but storing those items in a container for random indexing is by far the simplest:
#include <array> #include <cstdlib> #include <ctime> #include <iostream> using namespace std; int main() { srand((unsigned)time(nullptr)); array<int, 3> a = {11, 22, 33}; …
Jump to PostMy C is bit rusty but in pseudo code
(max_of_random - min_of__random)/(wanted_max-wanted_min)*random_value +wanted_min
All 8 Replies
shauzi158
-4
Newbie Poster
WaltP
commented:
Learn to use the function before telling someone how to wrongly use it.
-3
fadi_1234
-3
Light Poster
shauzi158
-4
Newbie Poster
Narue
5,707
Bad Cop
Team Colleague
fadi_1234
-3
Light Poster
TrustyTony
888
pyMod
Team Colleague
Featured Poster
WaltP
2,905
Posting Sage w/ dash of thyme
Team Colleague
mrnutty
761
Senior Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.