Ошибка
Run-Time Check Failure #2 - Stack around the variable 'mass' was corrupted.
Сам код -
#include <algorithm>
#include <iostream>
#include <ctime>
using namespace std;
int main()
{ // mass[i][j]
setlocale(LC_ALL, "rus");
const int n = 4;
const int m = 4;
int mass[n][m] = { 16,15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1 };
srand(time(NULL));
cout << "Случайно заполненный массив: " << endl;
for (int i = 0; i < n; i++)
{
for (int j = 0; j < m; j++)
{
/*mass[i][j] = rand() % 20;*/
}
}
for (int i = 0; i < n; i++)
{
for (int j = 0; j < m; j++)
{
cout << mass[i][j] << "\t";
}
cout << endl;
}
cout << "Сортировка методом Пузырька: " << endl;
bool skip = false;
while (!skip) {
skip = true;
for (int i = 0; i < n; i++)
{
for (int j = 0; j < m; j++)
{
if (mass[i][j] > mass[i][j + 1]) {
swap(mass[i][j], mass[i][j + 1]);
skip = false;
}
}
}
}
for (int i = 0; i < n; i++)
{
for (int j = 0; j < m; j++)
{
cout << mass[i][j] << "\t";
}
cout << endl;
}
}
Вывод в консоли -