Помогите разобраться как сортировать только данный "диапазон" матрицы

На картинке матрица 10х10 разделенная на 4 части, в которой правая четверть сортируется методом вставок по рядам.

Вот что у меня есть на данный момент. Заранее благодарен за помощь.

#include <iostream>
#include <ctime>
using namespace std;

int main()
{
srand(time(0));

const int size = 10;
int matrix[size][size];

system("mode con cols=100 lines=70");

cout << "Source matrix 10x10" << endl;
cout << endl;

for (int i = 0; i < size; i++)
{
    for (int j = 0; j < size; j++)
    {
        matrix[i][j] = rand() % 10;   
    }
}

for (int i = 0; i < size; i++)
{
    for (int j = 0; j < size; j++)
    {
        cout << matrix[i][j] << "\t";
    }
    cout << endl << endl;
}

cout << endl;
cout << "Transformed matrix 10x10" << endl;

int temp;
for (int s = 0; s < size; s++)
{
    for (int i = 0; i < size; i++)
    {
        for (int j = size - 1; j > i; j--)
        {
            if (matrix[s][j] < matrix[s][j - 1])
            {
                temp = matrix[s][j];
                matrix[s][j] = matrix[s][j - 1];
                matrix[s][j - 1] = temp;
            }
        }
    }
}

for (int i = 0; i < size; i++)
{
    for (int j = 0; j < size; j++)
    {
        cout << matrix[i][j] << "\t";
    }
    cout << endl << endl;
}

return 0;
system("pause");

}


Ответы (0 шт):