10分,学校作业,帮个忙
查看原帖
10分,学校作业,帮个忙
560714
Rainbow_Sky楼主2022/11/14 22:22
#include<bits/stdc++.h>
using namespace std;
int  m,n,k,l,d,xf,xs,yf,ys,h,li,han[1005],liel[1005];
struct node{
	int x,yf,ys;
}hang[10005];
struct data{
	int y,xf,xs;
}lie[10005];
bool cmp(node x,node y)
{
	return x.yf<y.yf;
}
bool dmp(data x,data y)
{
	return x.xf<y.xf;
}
bool gmp(int x,int y)
{
	return x>y;
}
int main()
{
	cin>>m>>n>>k>>l>>d;
	for(int i=1;i<=d;i++)
	 {
	 	cin>>xf>>yf>>xs>>ys;
	 	if(xf==xs)
	 	 {
	 	 	if(yf>ys)
	 	 	swap(yf,ys);
	 	 	h++;
	 	 	hang[h].x=xf;
	 	 	hang[h].yf=yf;
	 	 	hang[h].ys=ys;
		  }
		if(yf==ys)
	 	 {
	 	 	if(xf>xs)
	 	 	swap(xf,xs);
	 	 	li++;
	 	 	lie[h].y=yf;
	 	 	lie[h].xf=xf;
	 	 	lie[h].xs=xs;
		  }
	 }
	sort(hang+1,hang+1+h,cmp);
	sort(lie+1,lie+1+li,dmp); 
    
	for(int i=1;i<=h;i++)
	{
		han[hang[i].yf]=hang[i].yf;
	}
	for(int i=1;i<=li;i++)
	 {
	 	liel[lie[i].xf]=lie[i].xf;
	 }
	sort(han+1,han+1+1000,gmp);
	sort(liel+1,liel+1+1000,gmp);
	sort(han+1,han+1+l);
	sort(liel+1,liel+1+k);
	for(int i=1;i<=k;i++)
	 {
	 	cout<<liel[i]<<" ";
	 }
	 cout<<"\n";
	for(int i=1;i<=l;i++)
	 {
	 	cout<<han[i]<<" ";
	 }
	return 0;
}
2022/11/14 22:22
加载中...