Created
November 17, 2020 17:08
-
-
Save andresR8/cfd97fea02c8b1b31b446e88140286b8 to your computer and use it in GitHub Desktop.
poker_chips
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int getNumChips(int val){ | |
int chips[6]={100,50,25,10,5,1}; | |
int numChips=0; | |
size_t n = sizeof(chips)/sizeof(chips[0]); | |
for(int i=0; i<n; i++){ | |
numChips += val/chips[i]; | |
val = val % chips[i]; //only works if val is an integer | |
} | |
return numChips; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment