解题思路:
注意事项:
参考代码:
#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 人评分
字符串的输入输出处理 (C语言代码)浏览:699 |
C语言程序设计教程(第三版)课后习题6.7 (C语言代码)浏览:670 |
C语言程序设计教程(第三版)课后习题6.3 (C语言代码)浏览:544 |
简单的a+b (C语言代码)浏览:629 |
WU-图形输出 (C++代码)浏览:827 |
C语言程序设计教程(第三版)课后习题1.6 (C语言代码)浏览:681 |
C语言程序设计教程(第三版)课后习题1.6 (C语言代码)浏览:569 |
C语言训练-自由落体问题 (C语言代码)浏览:645 |
IP判断 (C语言描述,蓝桥杯)浏览:1108 |
C语言程序设计教程(第三版)课后习题3.7 (C语言代码)浏览:587 |