int anzahl1erdiag(int *m,int a,int b,int c){
int i,j,k,l,rv=0; for(j=0;j<=b-c;++j) for(i=0;i<=a-c;++i,rv+=l) for(k=0,l=1;l&&k<c;++k) if(m[(j+k)*a+i+k]!=1) l=0;
return rv; }
int main(){
int m[]={ 63, -34, 49, 10, 7, 13, -12, 7, -31, 23, 14, 1, 3, 4, 6, -1, 15, 14, 3, -12, 1, -7, 3, 9, -9, -7, -14, 8, 4, 1, 3, 2, -5, 9, -1, 1, 4, 6, -2, 2, 3, 0, -3, 2, 1, -2, 0, 4, 5, 11, 5, 6, 0, 3, -4, 4}; int a,b,c; a=8;b=7;c=2;
printf("%d\n",anzahl1erdiag(m,a,b,c));
}
|