cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
General C++ Programming
Randomizing string placement in an array
Randomizing string placement in an array
Jan 4, 2014 at 10:46pm UTC
closed account (
1b9vC542
)
I need to take my string of 6 words, then scramble them into a different order, then output to the console.
string line1[] = {
"I"
,
"Can"
,
"Do"
,
"That"
,
"Hold"
,
"My"
,
"Beer"
};
Jan 5, 2014 at 1:54am UTC
long double main
(999)
You can use
std::random_shuffle
in the
<algorithm>
header:
http://www.cplusplus.com/reference/algorithm/random_shuffle/
(Basically, it's just
random_shuffle(line1, line1+7);
in your case)
Topic archived. No new replies allowed.