题目 代码 #include <iostream> using namespace std; typedef long long ll; const ll maxn = 1e3 + 10; struct point { int x, y; }p[maxn]; int main() { int n; cin >> n; int a[5] = { 0,0,0,0,0 }; for (int i = 0; i < n; i++) { cin >> p[i].x >> p[i].y; } for (int i = 0; i < n; i++) { int x = p[i].x, y = p[i].y,f = 0,f2 = 0; for (int j = 0; j < n; j++) { if (p[j].x == x - 1 && p[j].y == y) f++; if (p[j].x == x + 1 && p[j].y == y) f++; if (p[j].x == x && p[j].y == y - 1) f++; if (p[j].x == x && p[j].y == y + 1) f++; if (p[j].x == x - 1 && p[j].y == y - 1) f2++; if (p[j].x == x - 1 && p[j].y == y + 1) f2++; if (p[j].x == x + 1 && p[j].y == y - 1) f2++; if (p[j].x == x + 1 && p[j].y == y + 1) f2++; } if (f == 4) { a[f2]++; } } for (int i = 0; i < 5; i++) { cout << a[i] << endl; } return 0; } 自己写的,100分