Vector Randomization Confusion

NOTE: If you can provide any help without suggesting anything having to do with "std::", that would be appreciated as my teacher says that is too complex for where I am in my course!

Goal:
Randomize the ordering of elements in a vector.

I am making Blackjack with a vector containing my cards:
 
	vector<string> deck {"Ace: Clubs","Ace: Diamonds","Ace: Hearts","Ace: Spades","2 of Clubs","2 of Diamonds","2 of Hearts","2 of Spades","3 of Clubs","3 of Diamonds","3 of Hearts","3 of Spades","4 of Clubs","4 of Diamonds", "4 of Hearts","4 of Spades","5 of Clubs","5 of Diamonds","5 of Hearts","5 of Spades","6 of Clubs","6 of Diamonds","6 of Hearts","6 of Spades","7 of Clubs","7 of Diamonds","7 of Hearts","7 of Spades","8 of Clubs","8 of Diamonds","8 of Hearts","8 of Spades","9 of Clubs","9 of Diamonds","9 of Hearts","9 of Spades","10 of Clubs","10 of Diamonds","10 of Hearts","10 of Spades","Jack of Clubs","Jack of Diamonds","Jack of Hearts","Jack of Spades","Queen of Clubs","Queen of Diamonds","Queen of Hearts","Queen of Spades","King of Clubs","King of Diamonds","King of Hearts","King of Spades"};


When I randomize the elements:
 
	random_shuffle(deck.begin(),deck.end());


It only randomizes them 1 way. For example, I get the same randomized order each time.

Is there a way to have the random ordering be different each time? Right now, I am basically just running the program, viewing the cards, then ending the program.

If say, I randomized it 2 times, would it show different results? How can my logic/syntax be revised/improved? I want to be able to run the program, see a random ordering, end the program, run it again, and see a different ordering, etc. Any help would be greatly appreciated.
The PRNG in this case is by default rand() more than likely and uses the default seed so at the beginning of your program you will need to change the seed. srand(time(nullptr)) or srand(time(0)); or better yet std::srand(static_cast<unsigned>(std::time(nullptr)));


For more information please read:
http://www.cplusplus.com/reference/algorithm/random_shuffle/ --random_shuffle
http://www.cplusplus.com/reference/algorithm/shuffle/ --c++11 shuffle

http://www.cplusplus.com/reference/cstdlib/srand/?kw=srand --srand (older seed)
http://www.cplusplus.com/reference/ctime/time/?kw=time

Keep in mind for srand you need to #include <cstdlib> and for time you need to #include <ctime>


Thanks, exactly what I needed!
Topic archived. No new replies allowed.