Could u please tell me why is this code not working?

The Lead Game

Problem Code: TLG

#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
cin>>n;
int lead = 0;
int leader = 0;
while(n–)
{
int play_1_marks = 0;
int play_2_marks = 0;
cin>>play_1_marks>>play_2_marks;
int diff = abs(play_2_marks - play_1_marks);
if(diff > lead)
{
lead = diff;
if(play_1_marks > play_2_marks)
{
leader = 1;
}
else
{
leader = 2;
}
}
}
cout<<leader<<" "<<lead;
return 0;
}

its n-- actually in the code

i dont know why everytime i copy paste it…it modifies to while(n-)

I think you did not the get the question, it states that at each round you have to take the cumulative score, meaning you have to keep adding the score of previous rounds to the current one and then check the difference.
At the end of each round, you are initializing the scores back to zero.

1 Like

ya sorry…i missed it…

i ll solve it now

thanks a lot.