Выдаёт Stack around the variable 'X' was corrupted.(Ну и Y соответственно)
#include <iostream>
#include <time.h>
#include <iomanip>
using namespace std;
void proc(int M[], int w, int e) {
int col = 0;
for (int i = 0; i < w; i++) {
for (int a = 0; a < e; a++) {
if (M[i*w+a] >= 0 && M[i*w+a] <= 1) {
col++;
}
}
}
cout << col << "\n";
}
void randF(int M[], int w, int e) {
for (int i = 0; i < w; i++) {
for (int a = 0; a < e; a++) {
M[i*w+a] = rand() % 10 - 5;
cout <<setw(3)<< M[i*w+a];
}
cout << "\n";
}
cout << "\n";
}
int main()
{
srand(time(NULL));
const int x1 = 10;
const int x2 = 15;
const int y1 = 20;
const int y2 = 12;
int X[x2][x1];
int Y[y2][y1];
randF(&X[0][0], x2, x1);
randF(&Y[0][0], y2, y1);
proc(&X[0][0], x2, x1);
proc(&Y[0][0], y2, y1);
return 0;
}