-22. Negative and Positive

I'm a slow walker, but I never walk backwards.

題目來源:judgegirl from ntu prof. pangfeng Liu

Task Description

Write a function posneg to find the number of positive and negative integers in a 5 by 5 integer array. The prototype of posneg is as follows.

1
void posneg(int array[5][5], int result[2]);

The number of negative integers should be place in result[0], and the number of positive integers should be place in result[1]. You only need to write the function and we will use a main program to test the correctness of your function.

The main program is as follows.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include <stdio.h>
#include "posneg.h"
int main() {
int i, j;
int array[5][5];
int result[2];
for (i = 0; i < 5; i++)
for (j = 0; j < 5; j++)
scanf("%d", &array[i][j]);
posneg(array, result);
printf("%d\n", result[0]);
printf("%d\n", result[1]);
return 0;
}

Input Format

There are five lines in the input. Each line has five integers.

Output Format

There are two lines in the output. The first line has the number of negative integers, and the second line has the number of positive integers in the matrix.

Sample Input

0 2 3 4 5
7 -7 7 7 7
8 9 -10 11 2
45 8 9 45 3
0 0 0 0 0

Sample Output

2
17

Submit

Login

Testdata Set

Download Testdata