Skip to content

Instantly share code, notes, and snippets.

@falsetru
Created December 3, 2011 05:28
Show Gist options
  • Save falsetru/1426168 to your computer and use it in GitHub Desktop.
Save falsetru/1426168 to your computer and use it in GitHub Desktop.
Bowling Game
#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;
}
@falsetru
Copy link
Author

falsetru commented Dec 3, 2011

3개월뒤 (2012/3/3)에 코드 읽어보고 바로 이해되는지 확인할것.

http://club.filltong.net/codingdojo/30302

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment