using namespace std;
int main()
{
int N, M;
cout << "Enter N: ";
cin >> N;
cout << "Enter M: ";
cin >> M;
srand(time(0));
vector> array(N, vector(M));
for (int i = 0; i < N; i++) {
for (int j = 0; j < M; j++) {
array[i][j] = rand() % 121 - 60; // Generate random numbers between -60 and 60
}
}
for (int i = 0; i < N; i++) {
for (int j = 0; j < M; j++) {
cout << array[i][j] << "\t";
}
cout << endl;
}
int lastPositive = -1;
for (int i = N - 1; i >= 0; i--) {
for (int j = M - 1; j >= 0; j--) {
if (array[i][j] > 0) {
lastPositive = array[i][j];
break;
}
}
if (lastPositive != -1) {
break;
}
}
cout << "Last positive element: " << lastPositive << endl;
return 0;
}
NATIJA: