为了找一点点bug,浪费了好多时间的我,今天依旧嘤嘤嘤~~~~
ps:结构体用得就是香。。。
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
struct Post{
int x1;
int x2;
int y1;
int y2;
int num;
};
int main()
{
int n,m;
cin>>n>>m;
struct Post post[20];
for(int i=0;i<n;i++)
{
cin>>post[i].x1>>post[i].y1>>post[i].x2>>post[i].y2;
post[i].num = i+1;
}
int x,y;
while(m--)
{
cin>>x>>y;
int x1,x2,y1,y2;
bool flag = false;
struct Post p;
for(int i=n-1;i>=0;i--)
{
if(x>=post[i].x1&&x<=post[i].x2&&y>=post[i].y1&&y<=post[i].y2)
{//若鼠标点击在窗口里面
cout<<post[i].num<<endl;
p = post[i];//注意这里,数据交换的时候不能只交换坐标值,还有num这个窗口序号
for(int j=i;j<n-1;j++)
{
post[j] = post[j+1];
}
post[n-1] = p;
flag = true;
break;
}
}
if(!flag)cout<<"IGNORED"<<endl;
}
return 0;
}