Scoring in blackjack is fairly simple. My C is rusty and I don't know what your input looks like, but you should be able to follow the below:
in score,aces;
for(i=0;i%26lt;n;i++){
select case card[i]{
case '2','3','4',5','6','7','8','9':
score+=card[i]-'0';
break;
case 'A':
score+=11;
aces+=1;
break;
default:
score+=10;
}
}
while(score%26gt;21 %26amp;%26amp; aces%26gt;0){
--aces;
score-=10;
}
Basically, count the score of each card - but note aces. If, by the end, you're over 21 try counting any aces as 1s instead of 11s.
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment