Friday, July 31, 2009

What is the logic of sum of diganal matrix in the programming in c?

program of sum of diganal matrix in c lang.?

What is the logic of sum of diganal matrix in the programming in c?
int sumDiag(int* matrix, int rows, int cols)


{


int sum = 0;


int size = rows %26gt; cols ? cols : rows; //choose the smaller one





for(int i = 0 ;i %26lt; size; i++)


sum+= *(*(matrix +i) + i); //add each diagonal item





return sum;


}


No comments:

Post a Comment