I need help making a vector to shuffle the deck of cards randomly as well as picking a card from the top of the deck, then discard a card back into the deck. The program should then reshuffle after cards have been discarded back into the deck.

#include <iostream>
using namespace std;

int main(int argc, char* argv[])
	int deck[52];
	int card;
	for (int i = 0; i< 52; i++)
		deck[i] = i;
		cout << deck[i] << " ";
	cout <<"\n" << endl;
	random_shuffle(&deck[0], &deck[52]);
	for (int p = 0; p< 52; p++)
		cout << deck[p] << " ";

	cout << "\n";
return 0;

Edited by WaltP: Added CODE Tags -- please use them

6 Years
Discussion Span
Last Post by pseudorandom21

I want to write the code of how to draw from a deck of cards, then discard a card back into the deck.


Please format your code properly. It will help you in the long run, and we won't get confused by misreading the code.

"draw from a deck of cards" is a little ambiguous. In detail, exactly what does it do? What happens to the deck?

Edited by WaltP: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.