Advertisement
ben1939

תרגיל 5 סעיף ב

Dec 4th, 2013
423
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<stdio.h>
  2.  
  3.  int neigh_sum(int arr[][SIZE], int row, int col)
  4. {
  5. int current_row, current_col, i, j, sum1 =0, sum2 =0;
  6.  
  7.         for (current_row = row - 1; current_row = < row + 1; current_row++) {
  8.           for (current_col = col - 1; current_col = < col + 1; current_col++) {
  9.                          
  10. if(current_row < 0)
  11.   i = SIZE - 1;
  12.    else if (current_row >= SIZE)
  13.       i = 0;
  14.          else i = current_row;
  15.            
  16.  if (current_col < 0)
  17.  j = SIZE - 1;
  18.    else if (current_col >= SIZE)
  19.         j = 0;
  20.       else j = current_col;
  21.            
  22. sum1 = sum1 + arr [i][j];  }    }
  23. sum2 = sum1 - arr[row][col];
  24.  
  25. returm sum2;
  26. }        
  27.                                            
  28.  
  29. void remove_cells(int arrSrc[][SIZE], int arrDst[][SIZE], int low, int high)
  30. {
  31.  
  32. int row, col;
  33.  
  34.     for (row=0; row < SIZE; row++){
  35.      for (col=0; col< size; col++){
  36.        if (low <= neigh_sum(arrSrc, row ,col) && neigh_sum(arrSrc, row ,col) <= high)  
  37.               arrDst[row][col] =  arrSrc [row][col] ;
  38.  
  39. else arrDst[row][col] = 0;    }   }
  40.  
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement