The Lead Game help

Hello,

can anybody point out to me what I am doing wrong? I read the assignment carefully (as suggested many times :wink: ), I compared my output to other successful submissions and got the same results but still my submission is not accepted.

#include <stdio.h>
#include <stdlib.h>

int main(void) {

    unsigned short N;
    scanf("%hu", &N);

    unsigned short score1, score2;
    // negative value = player2 is leading
    // positive value = player1 is leading
    int lead, biggest;
    unsigned int total1=0, total2=0;
    while(N-- > 0) {
        scanf("%hu %hu", &score1, &score2);

        total1 += score1;
        total2 += score2;

        lead = total1 - total2;

        if(abs(lead) >= abs(biggest)) {
            biggest = lead;
        }
    }

    // output
    if(biggest < 0) {
        printf("2 %d\n", abs(biggest));
    } else {
        printf("1 %d\n", abs(biggest));
    }
    
    return 0;
}

Thanks!

Got it. The problem is, that I used the variable โ€œbiggestโ€ without initializing it. Thus in the first if clause, a garbage value for biggest is used.

int lead, biggest;

should be

int lead, biggest=0;