Сортировка матрицы по убыванию суммы значений ее элементов, страница 3

    for ( i = 1 ; i < y ; i++ )

                               for(j = i; j > 0; j--)

                               {

                                               if (insert[j] > insert[j-1])

                                               {

                                                               temp = insert[j];

                                                               insert[j] = insert[j-1];

                                                               insert[j-1] = temp;

                                                               counter++;

                                                               for(int g = 0; g < x; g++)

                                                               {

                                                                              temp_matrix = matrix_insert[j][g];

                                                                               matrix_insert[j][g] = matrix_insert[j-1][g];

                                                                              matrix_insert[j-1][g] = temp_matrix;

                                                               }

                                               }

                               }

                cout << "*** insertion sort ***" << "\n" << "\n";

                for(i = 0 ; i < y ; i ++)

                {

                               for(j = 0; j < x ; j ++ ) 

                               {

                                               cout << " " << matrix_insert[i][j] << " ";

                               }

                               cout << endl;

    }

                cout << "\n";

                cout << "counter = " << counter << "\n"<<"\n";

//------------------------------ ñîðòèðîâêà ïóçûðüêîâàÿ ------------------------------------------

    counter = 0;

    temp=0;

                for (i = 0; i < y; i++)

                               for (j = y - 1 ; j > i ; j--)

                               {

                                               if (bubble[j] > bubble[j-1])

                                               {

                                                               temp = bubble[j];

                                                               bubble[j] = bubble[j-1];

                                                               bubble[j-1] = temp;

                                                               counter++;

                                                               for(int g = 0; g < x; g++)

                                                               {

                                                                              temp_matrix = matrix_bubble[j][g];

                                                                              matrix_bubble[j][g] = matrix_bubble[j-1][g];

                                                                              matrix_bubble[j-1][g] = temp_matrix;

                                                                              temp_matrix = matrix_shellk[j][g];

                                                                              matrix_shellk[j][g] = matrix_shellk[j-1][g];

                                                                              matrix_shellk[j-1][g] = temp_matrix;

                                                               }

                                               }

                               }