Position of "-1".
In the given NxM matrix find the LAST position of the minus one(-1). If it will be no "-1" value in the given matrix just output "-1 -1".
Input First line N and M (1<=N,M<=100). Then NxM table is given(all number are integers)
Output First number have to be the row number,and then column number of last "-1" element.
Here is my solution. But I have wrong answer.
#include <iostream>
#include <climits>
using namespace std;
int main () {
int row, col;
double x = 0, y = 0;
cin >> row >> col;
int matrix[row][col];
for (int i = 0; i < row; i++) {
for (int j = 0; j < col; j++) {
cin >> matrix[i][j];
if (matrix[i][j] < 0) {
x = i + 1;
y = j + 1;
}
}
}
if (x == 0 && y == 0)
x = -1, y = -1;
cout << x << " " <<y;
}