Blackjack (21) Programming Code

Hi guys,
So I am new to programming and I have to make a Blackjack (21) programming code.

I am in a programming class and this was homework assignment haha but I am having a bit of trouble. We have learned some loops and the most basic stuff but we haven't learned strings. We need to make it with what we know so strings is off the table.

I am using xcode in a mac. I know that macs aren't the best for programming but that's what I have for now. I am planning in buying a pc.

MY BASIC CONCERN is with the deck of cards, probability and the random numbers. I was planning in doing something like this:
deck=rand()%52+1; //or
deck=rand()%13+1;

since that is the standard deck in Blackjack, but I don't know how to make the numbers value something else.

What I want to do is this:
10, 11, 12, 13 = 10 but that is invalid so I am wondering how do I plot it.
1 (ace) = 1 or 11
and then all other numbers have their real value if I use the 13 card deck otherwise I would have to use the same system.

Any ideas?

Thanks :)
Basicly you need to know rank of card first. Then for cards that is not aces you need to return corresponding value. Something like:
1
2
3
4
int get_value(const Card& card)
{
    return (card.rank() < 10)? card.rank() : 10;
}
Aces are more complex. You should check them after total value of all other cards is calculated. After that you need to make as much aces to cost 11 points without going bust.
Topic archived. No new replies allowed.