I got it too

I submitted it as a snippet, others might find it kinda useful

Just a quick note, you might want to seed the random number with the system clock, like so:
cpp
#include <iostream> // input/output stream
#include <string> // string
#include <vector> // vector
#include <algorithm> // random_shuffle()
#include <ctime> // time()
using namespace std;
// pass a pointer to the deck and the name of the suit
void addSuit (vector <string> &deck, string suitName)
{
for (int i = 1; i <= 13; i++)
{
string str; // string to add to the deck
// put the string together
if (i < 10) str = i+48; // ASCII value of the number
if (i == 10) str = "10";
if (i == 11) str = "Jack";
if (i == 12) str = "Queen";
if (i == 13) str = "King";
str += " of " + suitName;
// add the string to the deck
deck.push_back (str);
}
}
int main ()
{
// create the deck
vector <string> deck;
// pass the deck and the suit name to add
addSuit (deck, "Hearts");
addSuit (deck, "Clubs");
addSuit (deck, "Spades");
addSuit (deck, "Diamonds");
// shuffle the deck
srand (time(NULL)); // seed the random number with the system clock
random_shuffle (deck.begin(), deck.end());
// create an iterator, to use for printing
vector <string>:: iterator It;
// loop through the deck
for (It = deck.begin(); It != deck.end(); ++It)
cout << *It << endl; // print the card value
cin.get (); // pause for input
return EXIT_SUCCESS;
}
This post has been edited by gabehabe: 23 Jun, 2008 - 04:14 PM