35. 零元素占比

单点时限: 1.0 sec

内存限制: 256 MB

计算一个由整数组成的两维数组中值为 $0$ 的元素的占比 (值的范围为 $[0,1]$)。数组由 $n$ 行组成,每行有 $m$ 个元素 ($1 \le n,m \le 100$)。

#include <stdio.h>

#define M 100

double Ratio(int (*p)[M], int n, int m)
/* PreCondition: 
 p points to a two-dimensional array with n lines and m integers in each line
    PostCondition: array is sorted satisfying to the specification
*/

{

}

int main() {
    int a[100][M], m, n, i, j;
    scanf("%d%d", &n, &m);
    for (i = 0; i < n; i++)
        for (j = 0; j < m; j++)
            scanf("%d", &a[i][j]);
    printf("%.9f\n", Ratio(a, n, m));
    return 0;
}

样例

Input
2 2
1 0
0 1
Output
0.500000000

325 人解决,351 人已尝试。

344 份提交通过,共有 785 份提交。

1.6 EMB 奖励。

创建: 6 年,3 月前.

修改: 6 年,3 月前.

最后提交: 1 周,4 天前.

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

题目标签