35. 零元素占比

单点时限: 1.0 sec

内存限制: 256 MB

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

#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

344 人解决,373 人已尝试。

365 份提交通过,共有 829 份提交。

1.5 EMB 奖励。

创建: 7 年,3 月前.

修改: 7 年,3 月前.

最后提交: 1 天,19 小时前.

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

题目标签