//刚开始,读了很久题目,也不是很明白题目的要求是什么!经过再三阅读,才明白!
//题目要求是:在给出的这么多个坐标中,取中间的坐标为原点,然后分别统计落在第一和第三象限,
//第二和第四象限的坐标点个数!
#include "iostream"
using namespace std;
struct Info
{
int x;
int y;
};
Info info[200010];
int main()
{
int n, i, j, ans1, ans2;
Info centerpoint;
while (cin >> n && n)
{
for (i = 0; i < n; i++)
cin >> info[i].x >> info[i].y;
j = (n-1) / 2;
ans1 = ans2 = 0;
centerpoint.x = info[j].x, centerpoint.y = info[j].y;
for (i = 0; i < n; i++)
{
if ((info[i].x > centerpoint.x && info[i].y > centerpoint.y) || (info[i].x < centerpoint.x && info[i].y < centerpoint.y))
ans1++;
else if ((info[i].x > centerpoint.x && info[i].y < centerpoint.y) || (info[i].x < centerpoint.x && info[i].y > centerpoint.y))
ans2++;
}
cout << ans1 << " " << ans2 << endl;
}
}
zoj 2554 Brownie Points
最新推荐文章于 2019-02-26 10:14:42 发布