Ray


私信TA

用户名:dotcpp0778684

访问量:110

签 名:

等  级
排  名 455
经  验 4726
参赛次数 0
文章发表 12
年  龄 0
在职情况 学生
学  校 第四小学
专  业

  自我简介:

TA的其他文章

解题思路:

注意事项:

参考代码:

#include <stdlib.h>
#include <stdio.h>
#include <iostream>
#include <string.h>
using namespace std;

int main(){
	int n;
	int x,y;
	scanf("%d",&n);
	int** point = (int**)malloc(sizeof(int*)*n);
	int i,j;
	for(i = 0;i<n;i++){
		point[i] = (int*)malloc(sizeof(int)*4);
		for(j = 0;j<4;j++){
			scanf("%d",&point[i][j]);
		}
	}
	scanf("%d",&x);
	scanf("%d",&y);
	
	int g,k;
	int x0,y0;
	int x1,y1;
	int f = -1;
	for(i = n-1;i>=0;i--){
		x0 = point[i][0];
		y0 = point[i][1];
		g = point[i][2];
		k = point[i][3];
		x1 = x0 + g;
		y1 = y0+ k;
		if(x >= x0 && x <= x1 && y >= y0 && y <= y1){
			f = i + 1;
			break;
		}
	}
	
	printf("%d\n",f);
	
	for(i = 0;i<n;i++){
		free(point[i]);
	}
	free(point);
	return 0;
}


 

0.0分

1 人评分

  评论区

  • «
  • »