#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAX_THROWS 21
int main(){
char input[100];
int throws[MAX_THROWS] = {0};
int score[10] = {0};
int throwIndex = 0, roundIndex = 0;
//input
//Rounds Parse
char *roundsToken
= strtok(input
, ":"); int numRounds
= atoi(roundsToken
); roundsToken
= strtok(NULL
, ":");
char *throwToken
= strtok(roundsToken
, ","); while (throwToken != NULL) {
throws
[throwIndex
++] = atoi(throwToken
); throwToken
= strtok(NULL
, ","); }
for(int i = 0, roundIndex = 0; roundIndex < numRounds; roundIndex++){
if (throws[i] == 10)
{
//if strike
score[roundIndex] = 10 + throws[i+1] + throws[i+2];
i++;
}
else if(throws[i] + throws[i+2] == 10){
//if spare
score[roundIndex] = 10 + throws[i+1];
i+=2;
}
else{
//if open
score[roundIndex] = throws[i] + throws[i+1];
i+=2;
}
if (roundIndex > 0)
{
score[roundIndex] += score[roundIndex - 1];
}
}
for (int i = 0; i < numRounds; i++) {
}
return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxzdGRsaWIuaD4KI2luY2x1ZGUgPHN0cmluZy5oPgoKI2RlZmluZSBNQVhfVEhST1dTIDIxCgppbnQgbWFpbigpewoKICAgIGNoYXIgaW5wdXRbMTAwXTsKICAgIGludCB0aHJvd3NbTUFYX1RIUk9XU10gPSB7MH07CiAgICBpbnQgc2NvcmVbMTBdID0gezB9OwogICAgaW50IHRocm93SW5kZXggPSAwLCByb3VuZEluZGV4ID0gMDsKCiAgICAvL2lucHV0CiAgICBwcmludGYoIklucHV0OiAiKTsKICAgIHNjYW5mKCIlcyIsIGlucHV0KTsKCiAgICAvL1JvdW5kcyBQYXJzZQogICAgY2hhciAqcm91bmRzVG9rZW4gPSBzdHJ0b2soaW5wdXQsICI6Iik7CiAgICBpbnQgbnVtUm91bmRzID0gYXRvaShyb3VuZHNUb2tlbik7CiAgICByb3VuZHNUb2tlbiA9IHN0cnRvayhOVUxMLCAiOiIpOwoKICAgIGNoYXIgKnRocm93VG9rZW4gPSBzdHJ0b2socm91bmRzVG9rZW4sICIsIik7CiAgICB3aGlsZSAodGhyb3dUb2tlbiAhPSBOVUxMKSB7CiAgICAgICAgdGhyb3dzW3Rocm93SW5kZXgrK10gPSBhdG9pKHRocm93VG9rZW4pOwogICAgICAgIHRocm93VG9rZW4gPSBzdHJ0b2soTlVMTCwgIiwiKTsKICAgIH0KCiAgICBmb3IoaW50IGkgPSAwLCByb3VuZEluZGV4ID0gMDsgcm91bmRJbmRleCA8IG51bVJvdW5kczsgcm91bmRJbmRleCsrKXsKICAgICAgICBpZiAodGhyb3dzW2ldID09IDEwKQogICAgICAgIHsKICAgICAgICAgICAgLy9pZiBzdHJpa2UKICAgICAgICAgICAgc2NvcmVbcm91bmRJbmRleF0gPSAxMCArIHRocm93c1tpKzFdICsgdGhyb3dzW2krMl07CiAgICAgICAgICAgIGkrKzsKICAgICAgICB9CiAgICAgICAgZWxzZSBpZih0aHJvd3NbaV0gKyB0aHJvd3NbaSsyXSA9PSAxMCl7CiAgICAgICAgICAgIC8vaWYgc3BhcmUKICAgICAgICAgICAgc2NvcmVbcm91bmRJbmRleF0gPSAxMCArIHRocm93c1tpKzFdOwogICAgICAgICAgICBpKz0yOwogICAgICAgIH0KICAgICAgICBlbHNlewogICAgICAgICAgICAvL2lmIG9wZW4KICAgICAgICAgICAgc2NvcmVbcm91bmRJbmRleF0gPSB0aHJvd3NbaV0gKyB0aHJvd3NbaSsxXTsKICAgICAgICAgICAgaSs9MjsKICAgICAgICB9CiAgICAgICAgCiAgICAgICAgaWYgKHJvdW5kSW5kZXggPiAwKQogICAgICAgIHsKICAgICAgICAgICAgc2NvcmVbcm91bmRJbmRleF0gKz0gc2NvcmVbcm91bmRJbmRleCAtIDFdOwogICAgICAgIH0KICAgICAgICAKICAgIH0KICAgIHByaW50ZigiT3V0cHV0OiAiKTsKICAgIGZvciAoaW50IGkgPSAwOyBpIDwgbnVtUm91bmRzOyBpKyspIHsKICAgICAgICBpZiAoaSA+IDApIHByaW50ZigiLCIpOwogICAgICAgIHByaW50ZigiJWQiLCBzY29yZVtpXSk7CiAgICB9CiAgICBwcmludGYoIlxuIik7CgogICAgcmV0dXJuIDA7Cn0=