Created
December 3, 2011 05:28
-
-
Save falsetru/1426168 to your computer and use it in GitHub Desktop.
Bowling Game
This file contains 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
#include <assert.h> | |
int frame_score(int *rolls) | |
{ | |
int total = 0; | |
for (int frames = 10; frames--; rolls += 1 + (*rolls < 10)) { | |
int score = rolls[0] + rolls[1]; | |
if (score >= 10) | |
score += rolls[2]; | |
total += score; | |
} | |
return total; | |
} | |
int main() | |
{ | |
int sample[] = {1,4,4,5,6,4,5,5,10,0,1,7,3,6,4,10,2,8,6}; | |
int perfect[] = {10,10,10,10,10,10,10,10,10,10,10,10}; | |
assert(frame_score(sample) == 133); | |
assert(frame_score(perfect) == 300); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
3개월뒤 (2012/3/3)에 코드 읽어보고 바로 이해되는지 확인할것.
http://club.filltong.net/codingdojo/30302