其他分享
首页 > 其他分享> > 201403-2

201403-2

作者:互联网

醉了,得了30分的代码,我到底哪里错了,该怎么验证
#include <bits/stdc++.h>
using namespace std;
struct node
{
int x1;
int y1;
int x2;
int y2;
node *next;
};
struct location
{
int x;
int y;
};
int main()
{
int n,m,a,b,c,d,flag=0;
location loc[10];
cin>>n>>m;
int i=0,j=n;
node *p,*pre,*head,*L;
head=new node;
head->next=NULL;
pre=head;
for(i=0;i<n;i++)
{
p=new node;
cin>>a>>b>>c>>d;
p->x1=a;
p->y1=b;
p->x2=c;
p->y2=d;
p->next=pre->next;
pre->next=p;
}
for(i=0;i<m;i++)
{
cin>>a>>b;
loc[i].x=a;
loc[i].y=b;
}
for(i=0;i<m;i++)
{
L=head->next;
pre=head;
j=n+1;
flag=0;
while(L!=NULL)
{
j–;
if(loc[i].x>=L->x1&&loc[i].x<=L->x2&&loc[i].y>=L->y1&&loc[i].y<=L->y2)
{
cout<<j<<endl;
flag=1;
pre->next=L->next;
p=L;
delete(L);
p->next=head->next;
head->next=p;
break;
}
else
{
pre=L;
L=L->next;
}
}
if(flag==0) cout<<“IGNORED”<<endl;
}
return 0;
}

标签:201403,loc,head,node,pre,int,next
来源: https://blog.csdn.net/qq_42790021/article/details/99731080