31. 距离小于 100!

单点时限: 1.0 sec

内存限制: 256 MB

定义函数 NearPoints,计算一组三维坐标点中离原点距离小于 $100$ 的点个数。点的类型定义为:

typedef struct {
    int x, y, z;
} Point;

//********** Specification of NearPoints **********
int NearPoints(Point *p, int n);
/* PreCondition: p 指向一个点的数组,n 是范围为 2-100 的点的个数
    PostCondition: 返回距离原点小于 100 的点的个数
*/

#include <stdio.h>

#define MAX 1000

typedef struct {
    int x, y, z;
} Point;

//********** Specification of NearPoints **********
int NearPoints(Point *p, int n) {

}

/***************************************************************/
int main() {
    int n, i;
    Point p[MAX];
    scanf("%d", &n);
    for (i = 0; i < n; i++) scanf("%d%d%d", &p[i].x, &p[i].y, &p[i].z);
    printf("%d\n", NearPoints(p, n));
    return 0;
}

输入格式

第一行一个整数 $n$ ($1 \le n \le 1000$)。

接下来 $n$ 行每行三个整数 $x_i,y_i,z_i$ ($-10^9 \le x_i,y_i,z_i \le 10^9$)。点坐标可能重复出现。

样例

Input
4
1 2 3
50 50 50
100 0 0
100 100 100
Output
2

695 人解决,824 人已尝试。

869 份提交通过,共有 4031 份提交。

1.8 EMB 奖励。

创建: 6 年,2 月前.

修改: 6 年,2 月前.

最后提交: 3 周,3 天前.

来源: 2017 程序设计基础期末考

题目标签