Quote:
What this code is showing output 0 0 on codechef?
When you ask for help about a codeChef challenge, it is a good idea to give link to that challenge, just in order to give a chance to know what you talk about.
Advice: never pack code on same line, it just makes code more difficult to read without any benefit:
#include<stdio.h>
int main()
{
int t,i,p1,p2,l=0,r=0;
scanf("%d",&t);
for(i=0;i<t;i++)
{
scanf("%d%d",&p1,&p2);
if(l>(p1-p2)|| l>(p2-p1))
{
if(p1>p2)
{
l=p1-p2;
r=1;
}
if(p2>p1)
{
l=p2-p1;
r=2;
}
}
}
printf("%d %d",r,l);
return 0;
}
Quote:
What this code is showing output 0 0 on codechef?
The only answer is 'because it is what you requested in your code'.
To get better answer, you need to tell what is supposed to do this code.