#include <iostream>
#define COLS 5
bool isRowSorted(int matrix[][COLS], int cols, int row) {
for (int i = 1; i < cols; i++) {
if (matrix[row][i - 1] > matrix[row][i]) {
return false;
}
}
return true;
}
int main() {
int matrix[][COLS] = { { 1, 2, 3, 4, 5 },
{ 5, 6, 100, 8, 1 },
{ 2, 200, 8, 400, 3 },
{ 1, 7, 300, 9, 6 },
{ 9, 10, 11, 12, 13 } };
int cols = sizeof matrix[0] / sizeof(int);
std::cout << "Row 0: " << isRowSorted(matrix, cols, 0) << std::endl;
std::cout << "Row 1: " << isRowSorted(matrix, cols, 1) << std::endl;
std::cout << "Row 2: " << isRowSorted(matrix, cols, 2) << std::endl;
std::cout << "Row 3: " << isRowSorted(matrix, cols, 3) << std::endl;
std::cout << "Row 4: " << isRowSorted(matrix, cols, 4) << std::endl;
}
/*
run:
Row 0: 1
Row 1: 0
Row 2: 0
Row 3: 0
Row 4: 1
*/