search - Find specific value in matrix algorithm -


i have matrix , want find algorithm can find values = 1 , give give me count of how many there are.

my matrix , have size n x n:

44444444 4 4 1  4 4 4  444 4444  44 4   1 34    444  444 44    44 44444444 

right don't know kind of algorithm have use.

if parsing problem then,

int count = 0; for(int i=0;i<n;i++) {     for(int j=0;j<n;j++)     {         if(isdigit(matrix[i][j] && matrix[i][j]!='0')         {             int sum = 0;             int tenpower = 1;             for(;j<n && isdigit(matrix[i][j];j++)             {                 sum = sum*tenpower+(matrix[i][j]-48);                 tenpower*=10;             }             if(sum == 1)count++;             j--;           }      }   }  printf("%d\n",count); 

Comments

Popular posts from this blog

java - Intellij Synchronizing output directories .. -

git - Initial Commit: "fatal: could not create leading directories of ..." -