Hi, i'd like to ask for some help about a problem i got... So i got this code right now:
Code:
const int rows = 5;
const int cols = 3;
int tocke = 0;
int tekmovalci[rows][cols]={{7, 6, 9},
{8, 7, 8},
{6, 9, 10},
{7, 7, 9},
{8, 8, 10}};
for(int r=0; r<rows; r++){
cout << r+1 << ". ";
for(int c=0; c<cols; c++){
cout << tekmovalci[r][c] << " ";
tocke += tekmovalci[r][c];
}
cout << tocke << endl;
tocke = 0;
}
and the 'int tocke' represents the sum of all numbers in a row, and now i'd like to sort the output by the value of sum.
this is the current output:
1. 7 6 9 22
2. 8 7 8 23
3. 6 9 10 25
4. 7 7 9 23
5. 8 8 10 26
and i want it like this:
5. 8 8 10 26
3. 6 9 10 25
2. 8 7 8 23
4. 7 7 9 23
1. 7 6 9 22