12 56 23 56 13 10 0 0 12 34 0 0 0 0
12 10 23 56 12 34 12 34
AC一:
#include<iostream>
#include<algorithm>
using namespace std;
int ls[100000], gq[100000];
int main()
{
int i=0;
while((cin>>ls[i]>>gq[i])&&(ls[i]||gq[i]))
{
i++;
while((cin>>ls[i]>>gq[i])&&(ls[i]||gq[i]))
i++;
sort(ls,ls+i);
sort(gq,gq+i);
cout<<ls[0]<<" "<<gq[0]<<" "<<ls[i-1]<<" "<<gq[i-1]<<endl;
i=0;
}
return 0;
}
AC二:
#include<iostream>
#include<algorithm>
using namespace std;
struct co
{
int x;
int y;
}per[10000];
bool cmp1(co a,co b)
{
return a.x<b.x;
}
bool cmp2(co a,co b)
{
return a.y<b.y;
}
int main()
{
int x,y,i=0;
while(1)
{
i=0;
while((cin>>per[i].x>>per[i].y)&&(per[i].x||per[i].y))
{i++;}
if(!i)
{
break;
}
sort(per,per+i,cmp1);
int k=per[0].x;int m=per[i-1].x;
sort(per,per+i,cmp2);
int l=per[0].y;int u=per[i-1].y;
cout<<k<<" "<<l<<" "<<m<<" "<<u<<endl;
}
return 0;
}
原文地址:http://blog.csdn.net/lsgqjh/article/details/44949225