#include<iostream> //#include<bits/stdc++.h> #include<cmath> #include<cstring> #include<algorithm> #include<cstdio> #include<malloc.h> #include<sstream> #include<string.h> #include<ctime> using namespace std; typedef long long ll; typedef unsigned long long ull; bool cmp(int a, int b) { return a > b; } struct REC { int x1; int y1; int x2; int y2; }; struct REC rec[10005]; int area_rec(struct REC a, struct REC b) { int area; int x1, y1; int x2, y2; x1 = max(a.x1, b.x1); y1 = max(a.y1, b.y1); x2 = min(a.x2, b.x2); y2 = min(a.y2, b.y2); if (x2 > x1 && y2 > y1) { area = (x2 - x1) * (y2 - y1); } else area = 0; return area; } int main() { int T; int n; int num[10005]; int region[10005]; memset(num, 0, sizeof(num)); memset(region, 0, sizeof(region)); cin >> T; while (T--) { cin >> n; for (int i = 0; i < n; i++) { cin >> rec[i].x1 >> rec[i].y1 >> rec[i].x2 >> rec[i].y2; } for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { if (i != j) { //自己和自己不做判定 int area = area_rec(rec[i], rec[j]); if (area != 0) { region[i]++; num[i] += area; } } } } for (int i = 0; i < n; i++) { cout << region[i] << " " << num[i] << endl; } } return 0; }
我打印出的结果是这样的,但是无法AC
0.0分
1 人评分
C语言程序设计教程(第三版)课后习题5.7 (C语言代码)浏览:762 |
简单编码 (C++代码)浏览:731 |
C语言训练-排序问题<2> (C++代码)浏览:936 |
数组输出 (C语言代码)错误???浏览:602 |
C语言程序设计教程(第三版)课后习题5.7 (C语言代码)浏览:591 |
C语言程序设计教程(第三版)课后习题7.1 (C语言代码)浏览:642 |
C语言程序设计教程(第三版)课后习题8.7 (C语言代码)浏览:609 |
DNA (C语言描述,蓝桥杯)浏览:1653 |
1025题解浏览:796 |
循环入门练习6 (C语言代码)浏览:1058 |