Code:
#include <iostream>
#include <cmath>
#include <ctime>
#include <cstdlib>
using namespace std;
int drawCard();
int main()
{
int i;
for(i = 1; i < 53; i++){
cout<< "Card "<< i<< " is "<< drawCard()<< ".\n";
}
}
int drawCard() {
int deck[53];
int loop;
while(loop != 0) {
int deck[53] = {0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,6,6,6,6,7,7,7,7,8,8,8,8,9,9,9,9,10,10,10,10,11,11,11,11,12,12,12,12,13,13,13,13};
loop = 0;
}
int cardToDraw;
time_t now;//Sets now to equal the current time.
time(&now);
srand(now++);//Uses the current time as the seed for random numbers.
cardToDraw = 0;//Draws the 0 card. This is needed to start the loop.
while(deck[cardToDraw] == 0) {//If the chosen card is gone, it will choose a new one.
cardToDraw = (rand() % 52);//Generates a random number between 0 and 52. This will be the card that is drawn.
cout<< "A card was chosen.\n";//Debugging line.
}
cout<< "cardToDraw = "<< cardToDraw<< ".\n";//Debugging line.
cout<< now;//Debugging line.
return cardToDraw;
deck[cardToDraw] = 0;//Removes the drawn card from the deck.
}
Forgive me if it's messy or full of problems; I'm pretty new to programming.