The Lead Game....HELP PLEASE

Can somebody please look at my code its submission. The program works just fine for me. The out put with any number entered is right and in the event of a tie the player who had the highest score first wins.

#include <stdio.h>
int main(int argc, const char * argv[])
{
int numberOfRounds;
int playerOne[10000], playerTwo[10000];
int diffOne[10000], diffTwo[10000];
int tieScore = 0;

scanf("%d", &numberOfRounds);

if(numberOfRounds <= 10000) {
for(int i = 0; i<numberOfRounds; i++){
    int pOne = 0, pTwo = 0;
    scanf("%d %d", &pOne, &pTwo);
    if((pOne > 0) && (pOne <= 1000)) {
        playerOne[i] = pOne;
    }
    else {
        break;
    }
    if((pTwo > 0) && (pTwo <= 1000)) {
        playerTwo[i] = pTwo;
    }
    else {
        break;
    }
}
}


int scoreOne = 0, scoreTwo = 0;

for(int j = 0; j<numberOfRounds; j++) {
        if(playerOne[j] > playerTwo[j]) {
        int score = playerOne[j] - playerTwo[j];
            diffOne[j] = score;
        if(score > scoreOne) {
            scoreOne = score;
        }
    }
        if(playerOne[j] < playerTwo[j]) {
        int score = playerTwo[j] - playerOne[j];
            diffTwo[j] = score;
        if(score > scoreTwo) {
            scoreTwo = score;
        }
    }
    
}

if(scoreOne > scoreTwo) {
    printf("%d %d \n", 1, scoreOne);
}
if(scoreOne < scoreTwo) {
    printf("%d %d \n", 2, scoreTwo);
}

if(scoreOne ==  scoreTwo) {
    tieScore = scoreOne;
    for(int k = 0; k<numberOfRounds; k++) {
        if(diffOne[k] == tieScore) {
            printf("%d %d \n", 1, tieScore);
            break;
            
        }
        if(diffTwo[k] == tieScore) {
            printf("%d %d \n", 2, tieScore);
            break;
        }
    }
}


return 0;

}

#include<stdio.h>
int main()
{

int l1,l2=0,win,tempwin,s1=0,s2=0,c1,n,c2;
scanf("%d",&n);
for(int i=0;i<n;i++)
{
	scanf("%d %d",&c1,&c2);
	s1=s1+c1;

	s2+=c2;
	if(s1>s2) {
		l1=s1-s2;
		tempwin=1;
	}
	else {

		l1=s2-s1;
		tempwin=2;
	}
	if(l1>l2 && tempwin==1) {

		l2=l1;
		win=1;
	}

	else if(l1>l2 && tempwin==2) {

		l2=l1;
		win=2;
	}

	else;
}

printf("%d %d",win,l2);
return 0;

}

Try to understand this.

1 Like