1-форме заполнить случайными числами массив, а[N][M] в отрезке [N; М]. Значения N и М вводится через компоненту TextBox. Вывести во 2-форме в компоненте label наибольшее значение среди трехзначных значений элементов массива. (сделать в c++)
int N, M; std::cout << "Enter the values of N and M for the array: "; std::cin >> N >> M; int a[N][M]; // Fill the array with random numbers in the range [N, M] for (int i = 0; i < N; i++) { for (int j = 0; j < M; j++) { a[i][j] = rand() % (M - N + 1) + N; std::cout << a[i][j] << " "; } std::cout << std::endl; } int maxThreeDigitValue = -1; // Find the maximum three-digit value in the array for (int i = 0; i < N; i++) { for (int j = 0; j < M; j++) { if (a[i][j] >= 100 && a[i][j] <= 999 && a[i][j] > maxThreeDigitValue) { maxThreeDigitValue = a[i][j]; } } } std::cout << "The maximum three-digit value in the array is: " << maxThreeDigitValue << std::endl; return 0;
int main() {
int N, M;srand(time(NULL));
std::cout << "Enter the values of N and M for the array: ";
std::cin >> N >> M;
int a[N][M];
// Fill the array with random numbers in the range [N, M]
for (int i = 0; i < N; i++) {
for (int j = 0; j < M; j++) {
a[i][j] = rand() % (M - N + 1) + N;
std::cout << a[i][j] << " ";
}
std::cout << std::endl;
}
int maxThreeDigitValue = -1;
// Find the maximum three-digit value in the array
for (int i = 0; i < N; i++) {
for (int j = 0; j < M; j++) {
if (a[i][j] >= 100 && a[i][j] <= 999 && a[i][j] > maxThreeDigitValue) {
maxThreeDigitValue = a[i][j];
}
}
}
std::cout << "The maximum three-digit value in the array is: " << maxThreeDigitValue << std::endl;
return 0;
}