I'm having issues correcting my code to check for the longest strictly increasing sequence in a 2D array.
This is the sample grid:
-1 3.14 42
0.2 2.7172
0.5 1.4142 -0.5 0 -0.5 0
0 0.577
10000 9999.99 -3 10
1 1 1 1 1
I have 4 functions that I pass into main and right now I'm trying to fix the first one since none of them worked correctly.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
|
int lookRight(double** grid, int num_rows, int* col_count, int i, int j) {
int length_size = 0;
int max_row_right = 0;
for (int n = j; n < col_count[i]; n++){
if (grid[i][n+1] > grid[i][n] && grid[i][n+1] != grid[i][n]){
length_size++;
cout << grid[i][n] << " " << grid[i][n+1] << endl;
max_row_right = length_size;
cout << "max_row_right: " << max_row_right << endl;
}
}
max_row_right = length_size;
cout << "Out of the entire grid, the max count in rows is: " << max_row_right << endl;
return max_row_right;
}
|
Right now it prints:
-1 3.14
max_row_right: 1
3.14 42
max_row_right: 2
Out of the entire grid, the max count in rows is: 2
3.14 42
max_row_right: 1
Out of the entire grid, the max count in rows is: 1
Out of the entire grid, the max count in rows is: 0
0.2 2.7172
max_row_right: 1
Out of the entire grid, the max count in rows is: 1
Out of the entire grid, the max count in rows is: 0
0.5 1.4142
max_row_right: 1
-0.5 0
max_row_right: 2
-0.5 0
max_row_right: 3
Out of the entire grid, the max count in rows is: 3
-0.5 0
max_row_right: 1
-0.5 0
max_row_right: 2
Out of the entire grid, the max count in rows is: 2
-0.5 0
max_row_right: 1
-0.5 0
max_row_right: 2
Out of the entire grid, the max count in rows is: 2
-0.5 0
max_row_right: 1
Out of the entire grid, the max count in rows is: 1
-0.5 0
max_row_right: 1
Out of the entire grid, the max count in rows is: 1
Out of the entire grid, the max count in rows is: 0
0 0.577
max_row_right: 1
Out of the entire grid, the max count in rows is: 1
Out of the entire grid, the max count in rows is: 0
-3 10
max_row_right: 1
Out of the entire grid, the max count in rows is: 1
-3 10
max_row_right: 1
Out of the entire grid, the max count in rows is: 1
-3 10
max_row_right: 1
Out of the entire grid, the max count in rows is: 1
Out of the entire grid, the max count in rows is: 0
Out of the entire grid, the max count in rows is: 0
Out of the entire grid, the max count in rows is: 0
Out of the entire grid, the max count in rows is: 0
Out of the entire grid, the max count in rows is: 0
Out of the entire grid, the max count in rows is: 0