-6

I have this matrix:

1 1
1 2
2 1
2 2

I want to count the occurrences of the row that have values 1 1 in it's columns. How do I do it?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459

1 Answers1

-2

Here is the not-so-scalable C way.

#include <stdio.h>
int main(void){
    int matrix[4][2] = {{1,1},{1,2},{2,1},{2,2}};
    int i, j, counter=0;
    for (i=0;i<4;i++)
    {
        if (matrix[i][0] == 1 && matrix[i][1] == 1)
            counter++;
    }
    printf("count %d", counter);
}
Arne
  • 1,293
  • 1
  • 7
  • 20