#include <iostream>
#include <stdlib.h>
#include <time.h>
#define N 4
#define M 4

void func(int B[N][M], int n, int m, int L)
{
if(n+m>0)
{
if(B[n][m]%(n+m)) L++;
}
}

int main()
{
srand(time(0));

int A[N][M], k=0;

cout<<"Old array:"<<endl;

for(int i=0;i<N;i++)
{
for(int j=0;j<M;j++)
{

A[i][j]=-5+rand()%30;

func(A,i,j,k);

cout<<A[i][j]<<"\t";
}
cout<<"\n\n";
}
cout<<"K="<< k <<endl;
system("pause");
return 0;
}