fork download
  1. #include <stdio.h>
  2. f(int m,int n,int**a,int*r){for(*r=m;n*m;a[m][n]?m--:--n);*r-=m;}
  3.  
  4. /* usage:
  5.   m = number of rows
  6.   n = number of columns
  7.   a = 1-based 2D array such that a[i][j] gives the value at the ith row and jth column
  8.   r = address of return value */
  9.  
  10. int main()
  11. {
  12. int flat[4*4] = {0, 0, 1, 0,
  13. 0, 0, 1, 0,
  14. 1, 0, 1, 1,
  15. 1, 1, 1, 1};
  16. int*twoD[4] = {flat-1,flat+3,flat+7,flat+11};
  17. int ret;
  18. f(4,4,twoD-1,&ret);
  19. printf("%d", ret);
  20. return 0;
  21. }
  22.  
Success #stdin #stdout 0s 2248KB
stdin
Standard input is empty
stdout
4