-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.c
57 lines (45 loc) · 814 Bytes
/
main.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include "matrix.h"
#include <assert.h>
int countZeroRows(matrix *m);
void test_countZeroRows()
{
const int arr[] =
{
1, 1, 0,
0, 0, 0,
0, 0, 1,
0, 0, 0,
0, 1, 1,
};
matrix m = createMatrixFromArray(arr, 5, 3);
assert(countZeroRows(&m) == 2);
outputMatrix(&m);
}
int countZeroRows(matrix *m)
{
int *row, count = 0;
bool answ;
for(int i = 0; i < m->nRows; i++)
{
row = m->values[i];
answ = true;
for(int j = 0; j < m->nCols; j++)
{
if(row[j] != 0)
{
answ = false;
break;
}
}
if(answ)
{
count++;
}
}
return count;
}
int main()
{
test_countZeroRows();
return 0;
}