[Solved] Count the occurences of rows based on it’s columns values


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);
}

0

solved Count the occurences of rows based on it’s columns values