Advertisement
Guest User

es2

a guest
May 5th, 2016
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.46 KB | None | 0 0
  1. int* mat_find(Mat* mat, int value, int* n){
  2.     int** matrix = mat->row_ptrs;
  3.     int rows = mat->rows;
  4.     int cols = mat->cols;
  5.     int cont = 0, k = 0;
  6.     for (int i=0; i<rows; i++){
  7.         for (int j=0; j<cols; j++){
  8.             if (matrix[i][j]>value) {
  9.                 cont=cont+1;
  10.             }
  11.         }
  12.     }
  13.     *n = cont;
  14.     int* vect = (int*)malloc(cont*sizeof(int));
  15.     for (int i=0; i<rows; i++){
  16.         for (int j=0; j<cols;j++){
  17.             if (matrix[i][j]>value){
  18.                 vect[k++]=i*cols+j;
  19.             }
  20.         }
  21.     }
  22.     return vect;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement