You are on page 1of 1

let us consider n number of points in x y coordinates

in all n number of points


either x coordinate is zero or y coordinate is zero
find out the max and min val of x and y coordinates from all n points

#include<stdio.h>

int main()
{
int n,xmax=0,ymax=0,xmin=0,ymin=0,max,min,x,y;
scanf("%d\n",&n);
while(n--)
{
scanf("%d %d\n",&x,&y);
if(x==0||y==0)
{
if(x>xmax)
xmax=x;
if(x<xmin)
xmin=x;
if(y>ymax)
ymax=y;
if(y<ymin)
ymin=y;

}
}
printf("%d %d %d %d",xmax,xmin,ymax,ymin);
}

You might also like