Simple function I can't get

Hey I really need to finish this right away. I'm basically trying to figure out bowling scores. These are the numbers in the file:
9,0,3,7,6,1,3,7,8,1,5,5,0,10,8,0,7,3,8,2,0

So the rolls would be 9-0, 3-7, 6-1, etc... If two rolls equal 10 then you would add the next roll to it. So this function should output
9 25 32 50 59 69 87 95 113 131


1
2
3
4
5
6
7
8
9
10
11
12
13
14
void ScoreGame(int score[], int NUMSCORES){
	int j=1, one=(j-1), two=(j), comp=score[0];
	for(j=1;j<NUMSCORES;j++){
		int next=(j+1);
		comp+=score[j];
		if(j%2!=0){
		cout << comp << "\t";
		
		if((score[one]+score[two])>=10){
			comp+=score[next];
		}
		}
	}
}


I know this is all messed up but I can't think anymore. If you could tell me what numbers I have wrong here that would be awesome. Thanks
Last edited on
Your expected output is incorrect.


This is pseudo code. It won't compile. But it should let you see where you're going wrong. It also makes no attempt to handle strikes correctly.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
total_score = 0

for i is 0 to numscores, step 2 (i+=2)
{
      if we're on the last 'extra' frame
            frame_value = score[i]
      else
      {
            frame_value = score[i] + score[i+1]

            if frame_value is 10
            {
                  if next frame is the last 'extra' frame
                        frame_value += score[i+2]
                  else
                        frame_value += score[i+2] + score[i+3]
            }
      }

      total_score += frame_value
      print total_score
} 
Topic archived. No new replies allowed.